【问题标题】:FCM notification with action button带有操作按钮的 FCM 通知
【发布时间】:2021-06-18 07:48:28
【问题描述】:

如果FirebaseMessagingService 中的onMessageReceived(remoteMessage: RemoteMessage) 仅在前台调用,而在后台显示默认通知,如何通过操作按钮显示自定义通知?

来自文档:

在后台时,应用在通知托盘中接收通知负载,并且仅在用户点击通知时处理数据负载。

在前台时,您的应用会收到一个消息对象,其中包含 可用的有效载荷。

doc link

我通过rest api发送data messages

https://fcm.googleapis.com/fcm/send


{
    "to": "my-token",
    "notification": {
      "title": "test title",
      "body": "test body"
      },

   "data": {
    "url": "test url",
      }
}

【问题讨论】:

    标签: android firebase-cloud-messaging


    【解决方案1】:

    似乎只有在使用 notification{} 字段时 onMessageReceived(remoteMessage: RemoteMessage) 在后台被忽略。

    适用于:

        {
          "to": "my-token",
          "data": {
          "url": "test url",
          }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-18
      • 1970-01-01
      • 2020-06-09
      • 2016-08-18
      • 2020-06-30
      • 1970-01-01
      • 2015-06-26
      • 2021-08-19
      相关资源
      最近更新 更多