【发布时间】:2020-05-24 17:38:22
【问题描述】:
我试图确保当用户单击推送通知气球时,应用程序会打开并转到特定页面。
我将 Nativescript 与 firebase 一起使用。这是app.component.tns.ts的代码段:
firebase.init({
showNotificationsWhenInForeground: true,
onMessageReceivedCallback: (message) => {
if (message.foreground) {
alert('app is open');
} else {
console.log('app background');
this.routerExtensions.navigate(["messages"] );
}
}
})
当应用程序在前台时,会显示警报,当应用程序在后台时,我点击通知,控制台日志会打印出来,但什么也没发生。
更新
当我在后台说应用程序时,这意味着应用程序仍然存在,当点击通知时,应用程序从启动屏幕启动。
【问题讨论】:
-
当你在后台说应用程序时,应用程序还活着还是被杀死?点击通知会让应用从闪屏开始?
标签: javascript typescript firebase push-notification nativescript