【发布时间】:2018-09-04 03:30:44
【问题描述】:
我可以向我的应用发送通知。 如果我的应用程序正在运行,那么它能够保存传入通知数据
如果我的应用程序已关闭并且我单击通知托盘上的通知,它会打开我的应用程序但不保存通知数据 关于在应用程序关闭时我们如何保存通知数据的任何建议? 下面是代码
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 检查以保存消息无论如何。
【问题讨论】:
标签: typescript firebase ionic-framework firebase-cloud-messaging cordova-plugin-fcm