FCM with ionic 2 in background not working(离子 2 在后台的 FCM 无法正常工作)
问题描述
如果我的应用程序关闭,点击通知栏后,回调不起作用.
If my application is closed, after click to notification bar, the callback not working.
前台不错,后台不行.
我使用这个例子:https://ionicframework.com/docs/native/fcm/
我在 Andoird 上测试
I test on Andoird
谢谢
推荐答案
当应用程序处于后台以获取点击回调时,您可能需要更改发送到 FCM api 的通知和数据负载,如下所示.此处 click_action 应为 FCM_PLUGIN_ACTIVITY 以使点击正常工作.请参阅 fcm 插件文档中的发送通知.有效负载示例(REST API)"部分
When app is in background in order to get the click call back you might need to change the notification and data payload sending to the FCM api as below. Here the click_action should be FCM_PLUGIN_ACTIVITY in order to get the click to work properly. Refer the "Send notification. Payload example (REST API)" part in the fcm plugin documentation
{
"notification":{
"title":"title",
"body":"message",
"sound":"default",
"click_action":"FCM_PLUGIN_ACTIVITY"
},
"data":{
"title":"title",
"body":"message",
"param1":"value1",
"param2":"value2"
},
"to":"token..."
}
这篇关于离子 2 在后台的 FCM 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:离子 2 在后台的 FCM 无法正常工作
基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
