【问题标题】:Go to a specific page when clicking on a notification单击通知时转到特定页面
【发布时间】:2018-03-08 05:33:56
【问题描述】:

点击通知时如何转到特定页面? 我使用 Firebase 控制台推送通知 我是这样用的。但它没有工作

fcm.onNotification().subscribe(data=>{
  if(data.wasTapped){
this.navcntrl.push(MessagePage); 
  };
})

我怎样才能正确地做到这一点?

我的完整代码:app.component.ts

 export class MyApp {
      @ViewChild(Nav) nav: Nav;

      rootPage: any = HomePage;
      pages: Array<{title: string, component: any}>;
      constructor(public platform: Platform,private fcm: FCM, public statusBar: StatusBar, public splashScreen: SplashScreen) {

        fcm.onNotification().subscribe(data=>{
          this.nav.push(ListPage)
        })
        this.initializeApp();
        this.pages = [
          { title: 'Home', component: HomePage },
          { title: 'List', component: ListPage }
        ];

      }

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

          this.statusBar.styleDefault();
          this.splashScreen.hide();
        });
      }

      openPage(page) {

        this.nav.setRoot(page.component);
      }
    }

提前致谢

【问题讨论】:

  • 请帮帮我,很紧急

标签: ionic-framework ionic3 cordova-plugin-fcm


【解决方案1】:

我解决了这个问题。 您必须将属性“click_action”:“FCM_PLUGIN_ACTIVITY”添加到“通知”对象才能正确使用后台方法。

例子:

{
 "to" : "tokenHere",
 "notification" : {
     "title": "title",
     "body" : "message",
     "sound": "default",
     "click_action":"FCM_PLUGIN_ACTIVITY"
 },
 "data": {
    "content": "whatever",
 },
 "priority":"high"
}

并使用 FCM API。不要使用 firebase 控制台。

【讨论】:

  • 您好,如何打开特定页面?如果我想打开一个特定的页面,你如何链接它?页面类名在哪里?请您详细说明一下?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多