0
我使用这个插件https://github.com/phonegap/phonegap-plugin-push
取得Ionic2应用程序,并发出通知。当用户收到通知时,根据其数据,我希望他们相应地移动页面。Ionic2推送通知页面移动
我送route
到additionalData
区分来引导他们的页面。除此之外,我想引导用户访问该页面的特定标签。
任何建议或意见,将不胜感激!
预先感谢您。
app.components.ts
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
}
});
EDITED:
app.components.ts
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;
}
});
tabs.ts
constructor(private navParams: NavParams) {
if (TabIndex) {
this.index = TabIndex;
}
}
谢谢您的建议。有用!但是,还有一件事是,当我移动到特定页面时,标签区域被隐藏。我如何让选项卡不隐藏? 我已经试过“'tabsHideOnSubPages = “假”''上tabs.html'。但是,它适用于每个子页面,因此无法使用它。 有没有什么办法可以将'index'数据传递给tabs.ts而不用'this.nav.push'? – smchae
我编辑过的问题。基本上,我想使用全局变量'TabIndex',所以我可以在'tabs.ts'中使用它,但是,当我在tabs.ts上使用TabIndex时,如何使用它? – smchae
嘿,我想你错了。 TabIndex不是在两者中都可以访问的全局变量。这对两个班都是本地的。所以,你在两个引用的TabIndex是不同的。可以尝试使用'localStorage'。 2.如果你不使用'this.nav.push()'或'this.nav.setRoot()',你会如何去首页的标签页? –