Я могу отправлять уведомления в свое приложение. Если мое приложение запущено, оно может сохранять данные о входящих уведомлениях.
Если мое приложение закрыто, и я нажимаю на уведомление на панели уведомлений, оно открывает мое приложение, но не сохраняет данные уведомлений. Есть предложения о том, как мы можем сохранить данные уведомлений, когда приложение закрыто? ниже код
platform.ready().then(() => {
fcm.onNotification().subscribe( data => {
this.con.notification_title = data.notification_title;
this.con.notification_message = data.notification_message;
if(localStorage.getItem('oldmsg'))
{
this.temparr = JSON.parse(localStorage.getItem('oldmsg'));
this.temparr.push({"notification_title":this.con.notification_title,"notification_message": this.con.notification_message});
localStorage.setItem('oldmsg',JSON.stringify(this.temparr));
this.presentToast("You Recieved A Message!");
}
else{
this.temparr.push({"notification_title":this.con.notification_title,"notification_message": this.con.notification_message});
localStorage.setItem('oldmsg',JSON.stringify(this.temparr));
this.presentToast("You Recieved A Message!");
}
});
statusBar.styleDefault();
splashScreen.hide();
this.storage.get('introShow').then((result) => {
if(result){
this.navCtrl.setRoot(LoginPage);
this.storage.set('introShow', true);
} else {
this.navCtrl.setRoot(IntroPage);
this.storage.set('introShow', true);
}
this.listenToLoginEvents();
});
});
Я удалил проверку data.wasTapped, чтобы сохранить сообщение, несмотря ни на что.