点击通知后,Ionic无法导航到特定选项卡?
问题描述:
我正在使用Ionic和FCM(firebase)插件发送推送通知。我可以收到通知,当我点击通知时,它会成功触发警报,但不会导航到指定的选项卡。只是为了确保这条线:点击通知后,Ionic无法导航到特定选项卡?
this.tab.select(2);
作品我已经测试与一个按钮,代码导航和它的作品
FCMPlugin.onNotification(function(data){
if(data.wasTapped){
//Notification was received on device tray and tapped by the user.
alert('data was tapped');
this.tab.select(2);
//this.navCtrl.push(ViewurgentnewsPage); also tried this
}else{
//Notification was received in foreground. Maybe the user needs to be notified.
alert('this was received on foreground');
}
});
答
您应该使用箭头功能
FCMPlugin.onNotification((data) => {
if(data.wasTapped){
//Notification was received on device tray and tapped by the user.
alert('data was tapped');
this.tab.select(2);
} else {
//Notification was received in foreground. Maybe the user needs to be notified.
alert('this was received on foreground');
}
});
通过使用箭头功能,this
关键字仍然引用组件代码,其中this.tab
属性存在。
非常感谢!那工作:D – Mikethetechy