当用户单击本地通知并希望根据其打开特定页面时,我正在尝试打开我的应用程序。下面给出的是我的示例代码,但它不会重定向到我给出的页面。
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.localNotification.on('click', (event, notification, state) => {
this.isNotification = true;
console.log(this.isNotification);
this.notificationData = notification;
});
setTimeout(()=>{
splashScreen.hide();
},500);
statusBar.styleDefault();
this.pushSettings();
if (localStorage.getItem("email")) {
if (localStorage.getItem("userName")) {
this.rootPage = TabstorePage
} else {
console.log(this.isNotification);
if(this.isNotification == true){
console.log("SalePage");
this.rootPage = SalePage
}else{
console.log("TabsPage");
this.rootPage = TabsPage
}
}
} else {
this.rootPage = LoginPage
}
});
}
答案 0 :(得分:0)
对于电容器用户,有一个localNotificationActionPerformed
事件:
LocalNotifications.addListener('localNotificationActionPerformed', (payload) => {
// Redirect here
});
我这样使用它:
LocalNotifications.schedule({
notifications: [
{
id: 1,
title: 'Hello',
body: 'World',
extra: {
route: '/whatever',
},
},
],
});
LocalNotifications.addListener('localNotificationActionPerformed', (payload) => {
const route = payload.notification.extra.route;
// use route to redirect
});