【发布时间】:2017-09-13 15:12:46
【问题描述】:
最近,我一直在我的应用程序中添加推送通知功能。我正在使用在 link 上找到的 FCN 插件,并且我使用 Ionic 2 框架进行开发。通知已发送,但当我点击它时,它只会打开应用程序的主页,而不是我需要的内页。
我用过这段代码
declare var FCMPlugin;
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;
horoscopePage:any = HoroscopeHomePage;
@ViewChild(Nav) nav: Nav;
**********************
FCMPlugin.onNotification(function(data){
if(data.wasTapped){
//Notification was received on device tray and tapped by the user.
if(data.topic =="horoskopi" && data.type=="list"){
console.log( JSON.stringify(data) );
this.nav.push(this.horoscopePage);
}
}else{
if(data.topic =="horoskopi" && data.type=="list"){
console.log( JSON.stringify(data) );
this.nav.push(this.horoscopePage);
}
}
});
});
不知何故,这行代码this.nav.push(this.horoscopePage); 没有做任何事情
当我改用 NavController 时,它给了我这个错误:
MyApp_Host.html:1 ERROR Error: No provider for NavController!
at injectionError (core.es5.js:1231)
at noProviderError (core.es5.js:1269)
at ReflectiveInjector_._throwOrNull (core.es5.js:2770)
at ReflectiveInjector_._getByKeyDefault (core.es5.js:2809)
at ReflectiveInjector_._getByKey (core.es5.js:2741)
at ReflectiveInjector_.get (core.es5.js:2610)
at AppModuleInjector.NgModuleInjector.get (core.es5.js:3578)
at resolveDep (core.es5.js:11039)
at createClass (core.es5.js:10903)
at createDirectiveInstance (core.es5.js:10723)
【问题讨论】:
标签: ios cordova ionic2 cordova-plugin-fcm