当应用程序在android中关闭时,是否可以将Firebase主题通知保存在sqlite中

Hit*_*hGs 6 android firebase

当我发送Firebase主题通知时,onMessageReceived方法在应用程序进入时不会触发

  1. 背景和屏幕锁定
  2. 申请与最近的申请截然不同

在上面两种情况下,我只在系统托盘中收到通知,我想在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)

提前致谢

him*_*009 0

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