打开本地通知的特定页面,单击“离子”

问题描述 投票:1回答:1

当用户单击本地通知并希望根据其打开特定页面时,我正在尝试打开我的应用程序。下面给出的是我的示例代码,但不会重定向到我给出的页面。

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
      }
    });
  }
android ionic-framework android-notifications localnotification
1个回答
0
投票

我必须面对同样的问题,这是我的方法。

在应用程序组件中,在initializeApp()中,调用可订阅的可观察的服务功能,如下所示:

initializeApp(){//in app components
...
this.localnotification.initHandler();//call to function in service

这是在本地通知服务中

initHandler(){
this.localNotifications.on("click").subscribe(res =>{
  console.log(res);
  if (res.data.redirect != null && res.data.redirect != undefined){
    //make redirect to place you want
  }
});

我希望对某人有用。

© www.soinside.com 2019 - 2024. All rights reserved.