Hi,
Recently i started to use Ionic’s push notifications. I can receive them either if the app is open or of it is closed.
The issue is: if the app is closed i just see the notification and when i click it, the app opens up, but i cannot see the message or use the additional data in it.
Is there a way to use that data?
I tried to have this snippet in the constructor of app.component.ts, but it works only when the app is open:
platform.ready().then(() => {
//Subscribe for the push noticiations
this.push.rx.notification().subscribe((msg) => {
//To get payload from the push msg.raw.additionalData which is an object
//Comes up when the app is in foreground
if (msg.raw.additionalData.foreground) {
this.toastCtrl.create({
message:msg.text,
duration:12000,
position: 'middle'
}).present();
} else {
//Should popup when the app was waken up.
alert(msg.raw.additionalData);
}
});
});