当我发送Firebase主题通知时,onMessageReceived方法在应用程序进入时不会触发
在上面两种情况下,我只在系统托盘中收到通知,我想在sqlite中以编程方式处理它
以及在最近的应用程序中列出的前景和后台应用程序的工作
所以我如何得到那个通知,我想在sqlite中存储通知
我的邮递员请求如下
{
"to": "/topics/181_Red_Route",
"data": {
"sound": "default",
"badge": "1",
"title": "Title1",
"body": "Desc1"
},
"notification": {
"sound": "default",
"badge": "1",
"title": "Title1",
"body": "Desc1"
},
"priority": "high",
"content_available": true
}
Run Code Online (Sandbox Code Playgroud)
提前致谢
https://firebase.google.com/docs/cloud-messaging/android/send-multiple
检查此链接,其中提到,有两种发送消息有效负载的方法。
1) 作为通知
2) 作为数据
如果服务器发送“数据”有效负载,那么它将在应用程序的onMessageReceived()方法中接收。您可以通过检查有效负载在onMessageReceived()中对其进行管理,如下所示。
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
Run Code Online (Sandbox Code Playgroud)
& 同时检查如何执行服务器代码,传递“通知”/“数据”。
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
| 归档时间: |
|
| 查看次数: |
3555 次 |
| 最近记录: |