[英]`on('notification')` is not triggered on iOS when app is not running
I'm using the phonegap-plugin-push
on my ionic3 app and I've been facing this issue with the iOS platform (android is ok). 我在ionic3应用程序上使用了phonegap-plugin-push
,并且在iOS平台上一直遇到此问题(android可以)。 When the app is in background/foreground everything works as expected. 当应用程序在后台/前景运行时,一切正常。 When the app is not running however, I get the message on the notification tray but neither tapping the notification or the app icon triggers the on('notification')
event, it simply runs and ignore the incoming notification. 但是,当应用程序未运行时,我会在通知托盘上收到消息,但是无论点击通知还是应用程序图标都不会触发on('notification')
事件,它只会运行并忽略传入的通知。
I'm using the { ... content-available: 1}
in the aps json message as suggested by the docs, but it doesn't seem to have any effect (though, it does have effect on Android), the ionic app itself never gets the message even though the device received it and displayed it on the tray. 我在docs所建议的aps json消息中使用了{ ... content-available: 1}
,但似乎没有任何效果(尽管它确实对Android起作用),离子应用程序即使设备收到了消息并将其显示在托盘上,它本身也从未收到消息。
Bellow, I show my configurations and a sample message sent to the push services. 在下面,我展示了我的配置和发送到推送服务的示例消息。 If anyone have any idea on how to sort this out will be appreciated, I've tested on ios 8.x and ios 11.x, both have presented the same behavior. 如果有人对如何解决这个问题有任何想法,我将在ios 8.x和ios 11.x上进行测试,它们都表现出相同的行为。
const options: PushOptions = {
android: {
senderID: '*************',
icon: 'ic_stat_ic_notification'
},
ios: {
alert: 'true',
badge: 'true',
sound: 'true'
},
windows: {}
};
platform.ready().then(() => {
push.on('registration').subscribe((data: EventResponse) => {
// register data.registrationId
});
push.on('notification').subscribe((data: EventResponse) => {
alert(data.message)
});
});
Sample message: 样本消息:
{
"aps": {
"alert": "This is a Push",
"badge": 1,
"content-available": 1
},
"payload": {
"type": "news"
}
}
This is too long of a comment. 这个评论太长了。 It's more of an indirect answer. 这更多是间接答案。
1) or the app icon triggers the on('notification') event <-- that's expected. 1) 或应用程序图标触发预期的on('notification')事件 <-。 Imagine your app just received 10 notifications. 假设您的应用刚刚收到10条通知。 How should it know which notification you intended to open? 它应该如何知道您打算打开哪个通知?
2) neither tapping the notification <-- this should trigger something in your code. 2) 均未点击通知 <-这将触发代码中的某些内容。 Do you have didReceiveNotificationResponse
implemented? 您是否已实施了didReceiveNotificationResponse
? Does that get called? 有电话吗? Or does your didFinishLaunching get launched with a remoteNotification
key? 还是您的didFinishLaunching使用remoteNotification
密钥启动了? How about your application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
does that get called? 调用您的application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
怎么样?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.