FCM与离子2在背景不起作用 [英] FCM with ionic 2 in background not working

查看:526
本文介绍了FCM与离子2在背景不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的应用程序关闭,点击通知栏后,回调不起作用。



我使用这个例子: https://ionicframework.com/docs/native/fcm/

我在Andoird上测试

谢谢 解决方案

当应用程序在后台,以获得点击回拨你可能需要改变通知和数据有效载荷发送到FCM api如下。这里的click_action应该是FCM_PLUGIN_ACTIVITY,以便点击正常工作。请参阅 fcm插件文档中的发送通知。有效负载示例(REST API)部分。 >

  {
notification:{
title:title,
body:message,
sound:default,
click_action:FCM_PLUGIN_ACTIVITY
},
data:{
title:title,
body:message,
param1:value1,
param2:value2
},
转换为:令牌...
}


If my application is closed, after click to notification bar, the callback not working.

It's good in foreground, but not in background.

I use this exemple : https://ionicframework.com/docs/native/fcm/

I test on Andoird

Thanks

解决方案

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..."
}

这篇关于FCM与离子2在背景不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆