Reputation: 63
I use an ionic app with the plugin phonegap-plugin-push (v2.1.0) to receive push notifications on my Android an iOS device.
So far it is working. When my app is in the background and I sent a notification, the notification will be sent to the device's system tray as a system notification. When I then click on the system notification it will appear inside my app
So in fact this event listener will be triggered:
this.pushObject.on('notification').subscribe(notification => {
....
});
But if I do not click on the system notification, but instead click on the app icon to open my app, the notification will not arrive inside my app. So this event listener seems not to be triggered.
I found a possible solution which will use the finish-Method:
this.pushObject.on('notification').subscribe(notification => {
....
this.pushObject.finish(notification.additionalData.notId);
});
Also I should sent "content_available": '1' for Android and "content_available": 1 for iOS, as well as the notification id (notId) for iOS (only for iOS???)
But nothing works.
Has someone a solution for that problem?
Upvotes: 2
Views: 813
Reputation: 2956
According to the plugin's Readme:
Note: if the push payload contained content-available: 1 then your notification event handler has already been called. It is up to you to handle the double event.
Therefore, when you launch the app the event has already been called and you don't see it again when reopening the app.
I'm almost certain that by design, your push event's won't be triggered when opening the app from the icon instead of the notification itself.
Upvotes: 1