Firebase onMessageReceived not called when app in background

前端 未结 26 2658
粉色の甜心
粉色の甜心 2020-11-22 02:32

I\'m working with Firebase and testing sending notifications to my app from my server while the app is in the background. The notification is sent successfully, it even appe

26条回答
  •  感情败类
    2020-11-22 03:18

    I was having the same issue and did some more digging on this. When the app is in the background, a notification message is sent to the system tray, BUT a data message is sent to onMessageReceived()
    See https://firebase.google.com/docs/cloud-messaging/downstream#monitor-token-generation_3
    and https://github.com/firebase/quickstart-android/blob/master/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/MyFirebaseMessagingService.java

    To ensure that the message you are sending, the docs say, "Use your app server and FCM server API: Set the data key only. Can be either collapsible or non-collapsible."
    See https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages

提交回复
热议问题