Firebase onMessageReceived not called when app in background

前端 未结 26 3284
粉色の甜心
粉色の甜心 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:10

    This is working as intended, notification messages are delivered to your onMessageReceived callback only when your app is in the foreground. If your app is in the background or closed then a notification message is shown in the notification center, and any data from that message is passed to the intent that is launched as a result of the user tapping on the notification.

    You can specify a click_action to indicate the intent that should be launched when the notification is tapped by the user. The main activity is used if no click_action is specified.

    When the intent is launched you can use the

    getIntent().getExtras();
    

    to retrieve a Set that would include any data sent along with the notification message.

    For more on notification message see docs.

提交回复
热议问题