0
在Ionic 2中,我試圖處理用戶當前在應用程序中的事件,以便我可以彈出警告消息並導航到不同的視圖。在我的應用程序構造函數中,我有以下代碼:當在Ionic 2中打開應用程序時處理推送通知
export class MyApp {
private rootPage: any;
constructor(private platform: Platform, private app: App, private push: Push) {
if (UserService.isLoggedIn()) { this.rootPage = PickupPage; }
else { this.rootPage = LoginPage; }
console.log('We are here! We are here! We are here!');
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.
console.log('Registering notifications handler');
this.push.rx.notification().subscribe(msg => {
alert(msg.title);
console.log('Got something!');
console.dir(msg);
});
StatusBar.styleDefault();
});
}
}
當我發送通知,在Android上我得到在Android的下拉條來了通知,但沒有控制檯或警告的內部應用程序和iOS我什麼都沒得到。通知中心沒有控制檯消息或警報,也沒有通知。
§ ionic -v
2.0.0-beta.37
如果你能做到推送通知,請更新您的答案,因爲很多人和我一樣在推送通知 –
都在努力@mohangopi我已經更新了答案。直到明天,我都不能將它標記爲答案。看來你每次打開應用程序都必須註冊通知。我還沒有挖掘出足夠的數據,但這裏是'register'的代碼https://github.com/driftyco/ionic-cloud/blob/master/src/push/push.ts#L214 –