且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当应用程序在后台运行时,在单击通知时未调用fcm.onNotification()

更新时间:2022-12-27 11:48:33

该通知应具有"click_action":"FCM_PLUGIN_ACTIVITY" ,以便触发onNotification(),因此不会如果您是从Firebase控制台发送邮件,则可以正常工作,请使用http reqquest发送通知,然后按照 Firebase Cloud Messaging HTTP协议文档可以提供更多的见解,我建议邮递员做到这一点,也是chrome插件.

the notification should have "click_action":"FCM_PLUGIN_ACTIVITY" for the onNotification() to be fired, so it would not work if you are sending it from firebase console, send the notification using http reqquest, follow Firebase Cloud Messaging HTTP Protocol documentation form more insights , and i recommend Postman to do it, it is also a chrome plugin.

您的代码应如下:

{
  "notification":{
    "title":"Notification title",
    "body":"Notification body",
    "sound":"default",
    "click_action":"FCM_PLUGIN_ACTIVITY", //this is needed so the onNotification() fires when notification is tapped
    "icon":"fcm_push_icon"
  },
  "data":{
    "param1":"value1",
    "param2":"value2"
  },
  "to":"/topics/topicExample"(or device token),
  "priority":"high"
}

参考:

Firebase云消息传递HTTP协议 >

这两个链接具有您所需的一切

those two links have everything you need

祝你好运.