Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在本地通知上打开特定页面,然后单击“打开”_Android_Ionic Framework_Android Notifications_Localnotification - Fatal编程技术网

Android 在本地通知上打开特定页面,然后单击“打开”

Android 在本地通知上打开特定页面,然后单击“打开”,android,ionic-framework,android-notifications,localnotification,Android,Ionic Framework,Android Notifications,Localnotification,当用户单击本地通知并希望根据该通知打开特定页面时,我正在尝试打开我的应用程序。下面给出的是我的示例代码,但它没有重定向到我给出的页面 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.

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

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
      }
    });
  }

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

在应用程序组件中,在initializeApp()中调用订阅observable的服务函数,如下所示:

initializeApp(){//in app components
...
this.localnotification.initHandler();//call to function in service
这是在localnotification服务中

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
  }
});

我希望这对某些人有用。

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

在应用程序组件中,在initializeApp()中调用订阅observable的服务函数,如下所示:

initializeApp(){//in app components
...
this.localnotification.initHandler();//call to function in service
这是在localnotification服务中

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
  }
});

我希望这对某人有用。

对于电容器用户,有一个
localNotificationActionPerformed
事件:

LocalNotifications.addListener('localNotificationActionPerformed',(有效负载)=>{
//重定向到这里
});
我是这样使用它的:

initializeApp(){//in app components
...
this.localnotification.initHandler();//call to function in service
LocalNotifications.schedule({
通知:[
{
id:1,
标题:“你好”,
正文:“世界”,
额外:{
路线:'/whatever',
},
},
],
});
LocalNotifications.addListener('localNotificationActionPerformed',(有效负载)=>{
const route=payload.notification.extra.route;
//使用路由重定向
});

对于电容器用户,有一个执行的
本地通知操作
事件:

LocalNotifications.addListener('localNotificationActionPerformed',(有效负载)=>{
//重定向到这里
});
我是这样使用它的:

initializeApp(){//in app components
...
this.localnotification.initHandler();//call to function in service
LocalNotifications.schedule({
通知:[
{
id:1,
标题:“你好”,
正文:“世界”,
额外:{
路线:'/whatever',
},
},
],
});
LocalNotifications.addListener('localNotificationActionPerformed',(有效负载)=>{
const route=payload.notification.extra.route;
//使用路由重定向
});