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). 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.
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.
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.
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. Imagine your app just received 10 notifications. How should it know which notification you intended to open?
2) neither tapping the notification <-- this should trigger something in your code. Do you have didReceiveNotificationResponse
implemented? Does that get called? Or does your didFinishLaunching get launched with a remoteNotification
key? How about your application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
does that get called?