【问题标题】:Redirecting to page in Ionic after clicking on notificacion单击通知后重定向到 Ionic 中的页面
【发布时间】:2017-09-04 20:04:04
【问题描述】:

我正在使用 Ionic 和 Firebase 测试 javebratt 的 fitCoach 推送通知示例。 javebratt/fitCoach

推送很好,但是当页面重定向发生时,我在手机上看到以下错误。

Error seen on device when clicking on notification, page redirection should happen here

Line in app.component.ts where navCtrl error is trigered

app.component.ts 中的代码如下:

platform.ready().then(() => {

    fcm.onNotification().subscribe( data => {
      if(data.wasTapped){
        authUnsubscribe.unsubscribe();
        //Notification was received on device tray and tapped by the user.
        console.log( JSON.stringify(data) );
        this.navCtrl.setRoot('ClientDetailPage', { 'clientId': data.clientId});
      }else{
        //Notification was received in foreground. Maybe the user needs to be notified.
        console.log( JSON.stringify(data) );
        this.navCtrl.push('ClientDetailPage', { 'clientId': data.clientId});
      }
    });


  // Okay, so the platform is ready and our plugins are available.
  // Here you can do any higher level native things you might need.
  statusBar.styleDefault();
  splashScreen.hide();
});

我从 github 克隆了他的 repo,有什么建议吗?

谢谢

【问题讨论】:

    标签: typescript ionic-framework


    【解决方案1】:

    javebratt 找到了答案,src/app/app.html 中缺少 #myNav

    https://github.com/javebratt/fitCoach/commit/f89d5dcdd0080c38727f889c70517fd219b5b44a

    【讨论】:

    • 作为旁注,在设备中测试应用程序时要小心更改令牌。将令牌记录到控制台以与 Firebase 进行比较并使用 fcm.onTokenRefresh。
    猜你喜欢
    • 1970-01-01
    • 2021-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    相关资源
    最近更新 更多