我在用户按下通知时遇到问题我的代码设置rootPage就是这个代码,这个代码在平台就绪回调函数中:
this._authService.isAuthenticated().subscribe(
success => {
console.log('DashboardPage');
this.rootPage = DashboardPage;
},
error => {
console.log('LoginPage');
this.rootPage = LoginPage;
},
() => {//After set the rootPage I call configPush
this.splashScreen.hide();
this.configPush();
}
)
我的配置推送功能:
private configPush() {
push.on('registration', (data) => {
console.log(JSON.stringify(data));
this._authService.setDeviceId(data.registrationId);
});
push.on('notification', (data) => {
console.log(JSON.stringify(data.additionalData));
if (data.additionalData.foreground) {
this.global.startToast(data.message)
} else {
if ((data.additionalData.contexto && data.additionalData.contexto == 'seguidores')) {
this.app.getRootNav().setRoot(DashboardPage, { contexto: 'seguidores' });
}
if ((data.additionalData.contexto && data.additionalData.contexto == 'evento')) {
console.log('entrou');
let evento = JSON.parse(data.additionalData.evento);
console.log(JSON.stringify(evento));
this.app.getRootNav().push(EventoPage, { evento: data.additionalData.evento });
}
}
});
}
当contexto ==' evento'时它实际进入if部分,但是rootNav中的推送没有被执行,或者它是否被执行没有任何反应,控制台没有任何错误,是我的代码正确吗?如何设置更改视图,通过我收到通知的params到我想要更改的视图