Hi !
I am using a phonegap-plugin-push for receiving notifications in ionic3 cordova app. I am deploying on android for testing.
When the app is in foreground (on screen) I receive the contents (title, message, data, etc.) properly and I am able to see them in alert box directly in the app.The function push.on(‘notification’, function(data) {} is called.
But when app is in background (not on screen but running in backround), I get the notification in Notification Area. When I click on the notification received, it is redirecting me to the last opened page in the app.
The function push.on(‘notification’, function(data) {} is not called. No alert messages are shown. Can someone help me how to access the notification message and data in background?
pushObject.on('notification').subscribe((notification: any) =>{
if (notification.additionalData.coldstart) {
console.log("background");
}
if(notification.additionalData.foreground) {
console.log("foreground");
}
});
foreground -> pushObject.on(‘notification’).subscribe((notification: any) is called
background -> pushObject.on(‘notification’).subscribe((notification: any) is not called, show default notoication