【发布时间】:2022-01-04 21:58:34
【问题描述】:
当应用程序在前台接收 FCM 推送通知但未显示 toast 消息时,我尝试显示 toast 消息,我放置了 alert(data.message) 并且警报显示没有问题但 toast 消息没有。顺便说一句,toast 消息在应用程序的其他页面中运行良好,但在 app.components.ts 中却没有
initializeApp() {
this.platform.ready().then(() => {
this.fcm.onNotification().subscribe(data => {
console.log(data);
if (data.wasTapped)
{
....
...
} else {
alert(data.message);
this.presentToast(data.message);
}
});
// refresh the FCM token
this.fcm.onTokenRefresh().subscribe(async token => {
console.log(token);
....
...
});
});
}
async presentToast(msg) {
const toast = await this.toast.create({
message: msg,
duration: 3000,
position: 'top'
});
await toast.present();
}
【问题讨论】:
-
你检查console.log有什么错误吗??
标签: android angular ionic-framework ionic5 cordova-plugin-fcm