Push notification Ionic2推送通知页面移动

Push notification Ionic2推送通知页面移动,push-notification,ionic2,cordova-plugins,Push Notification,Ionic2,Cordova Plugins,我使用这个插件制作了带有通知的Ionic2应用程序https://github.com/phonegap/phonegap-plugin-push. 当用户收到通知时,根据其数据,我希望他们相应地移动页面 我正在向其他数据发送路径,以区分要引导它们的页面。除此之外,我还想引导用户进入页面的特定选项卡 任何建议或建议将不胜感激 先谢谢你 app.components.ts 编辑: app.components.ts 制表符 您可以在Tabs.ts中设置navParams,就像在提到选项卡的位置一样

我使用这个插件制作了带有通知的Ionic2应用程序https://github.com/phonegap/phonegap-plugin-push. 当用户收到通知时,根据其数据,我希望他们相应地移动页面

我正在向其他数据发送路径,以区分要引导它们的页面。除此之外,我还想引导用户进入页面的特定选项卡

任何建议或建议将不胜感激

先谢谢你

app.components.ts

编辑:

app.components.ts

制表符

您可以在Tabs.ts中设置navParams,就像在提到选项卡的位置一样,在Tabs.html中,您可以使用设置它

您可以将选项卡的索引作为navParam发送到此tabs.ts。然后,在本页中使用

制表符:

tabs.html:


谢谢你的建议。它起作用了!然而,还有一件事是,当我移动到那个特定的页面时,选项卡区域是隐藏的。如何使选项卡不隐藏?我在tabs.html上尝试了'tabsHideOnSubPages=false'。但是,它适用于每个子页面,因此无法使用它。有没有办法在没有这个.nav.push的情况下将索引数据传递给tabs.ts?我已经编辑了这个问题。基本上,我想使用全局变量TabIndex,这样我就可以在tabs.ts中使用它,但是,当我在tabs.ts中使用TabIndex时,我该如何使用它呢?嘿,我想你搞错了。1。TabIndex不是在这两种情况下都可以访问的全局变量。这是本地的两个类。因此,您在这两个文档中引用的TabIndex是不同的。可以尝试使用本地存储。2.如果您不使用this.nav.push或this.nav.setRoot,您首先将如何转到选项卡页面?是的,我尝试使用TabIndex,但它不起作用。因此,我返回this.nav.push和this.nav.setRoot。但是,在使用this.nav.push时,我找不到保留选项卡区域的方法。我的rootPage将是TabsPage,因此我只需要选择tab而不是this.nav.push
declare var TabIndex: any; 

.....

push.on('notification').subscribe((notification:any) => {
    if (notification.additionalData.route == 'order-list') {
        console.log('order-list is selected');
        //WHAT DO I DO? 
        //I want the user to move to TabsPage(parent view) and its second-tab(child view)
    } else if (notification.additionalData.route == 'personal') {
        console.log('personal is selected');
        //I want the user to move to TabsPage and its third-tab
    } 
});
push.on('notification').subscribe((notification:any) => {
    if (notification.additionalData.AppRoute == 'order-list') {
        console.log('move to orderlist');
        // this.nav.push(TabsPage, {"index" : 1});
        TabIndex = 1;
    } else if (notification.additionalData.AppRoute == 'order-home') {
        console.log('move to home');
        // this.nav.push(TabsPage, {"index" : 0});
        TabIndex = 0;
    }
});
constructor(private navParams: NavParams) {
    if (TabIndex) {
        this.index = TabIndex;
    }
}
export TabsPage{
  index = 1;
  constructor(private navParams: NavParams){
    // This if() is for other cases where you don't want to send navParams. Like normally setting this page and selectedTab to 1.
    if(this.navParams.data.index !== undefined){
      index = this.navParams.data.index;
    }
  }
}
<ion-tabs selectedIndex={{index}}>
  <ion-tab>..</ion-tab>
  ...
</ion-tabs>
push.on('notification').subscribe((notification:any) => {
  if (notification.additionalData.route == 'order-list') {
    console.log('order-list is selected');
    this.nav.push(TabsPage, {"index" : 2});
  } else if (notification.additionalData.route == 'personal') {
    console.log('personal is selected');
    this.nav.push(TabsPage, {"index" : 3});
  } 
});