我正在开发一个离子应用程序,我正在使用FCM推送通知向用户发送通知 .
这是发送通知的JSON有效负载:
{
"to" : "access_token",
"priority": "normal",
"notification" : {
"body" : "this is message",
"title" : "notification Title"
},
"data": {
"link": ....
}
}
在这些不同的情况下收到推送通知:
-
当 the app is in background or it is killed - >用户将收到系统托盘推送通知
-
当 the app is in foreground and the user is in it - >用户将收到将更新应用程序的新数据
-
当 the app is in foreground and the screen is locked (系统认为它在后台) - >因此用户将收到系统托盘推送通知,但在解锁手机屏幕时, nothing happens in the app instance that were in foreground 直到我点击系统托盘中的推送通知 .
有没有办法获取系统托盘中的推送通知数据而不点击它?
2 回答
希望这项工作!对于Foreground,您可以使用 Local Notification 显示推送通知:
https://ionicframework.com/docs/native/local-notifications/
发送通知信息和数据对象,然后在您的离子项目中手动设置包含该数据的通知 .