Firebase onMessageReceived not called when app is in the background

后端 未结 4 1886
感情败类
感情败类 2020-11-28 11:38

I am using Firebase for our messaging service in our Android app. I have researched Firebase quite a bit and I understand that whether the app if running in the foreground o

4条回答
  •  清歌不尽
    2020-11-28 12:12

    Remove the notification payload from your FCM messages in order to have the data payload delivered to the onMessageReceived method.

    Read this and this carefully.

    When your app is in the background, data payload delivered to the onMessageReceived method only if there is no notification payload. (Mark the words)

    In case both payloads exist then system automatically handles the notification part (system tray) and your app gets the data payload in the extras of the intent of launcher Activity (after the user tap on the notification).

    In order to be able to serve both platforms successfully, Android and iOS, you may have to send different FCM messages according to client's OS.

提交回复
热议问题