FCM with ionic 2 in background not working [closed

2019-02-27 19:51发布

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

1条回答
聊天终结者
2楼-- · 2019-02-27 20:15

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..."
}
查看更多
登录 后发表回答