- pushsetup(){
const options: PushOptions = {
android: {
senderID: 'xxxxxxxxxx'
},
ios: {
alert: 'true',
badge: true,
sound: 'false'
},
windows: {},
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('notification').subscribe((notification: any) =>
{
if (notification.additionalData.foreground) {
let youralert = this.alertCtrl.create({
title: 'New Push notification',
message: notification.message
});
youralert.present();
} else {
// var navigate = notification.additionalData.nav;
}
});
pushObject.on('registration').subscribe((registration: any) =>
{
let youralert = this.alertCtrl.create({
title: 'New Push notification',
message: registration.registrationId
});
youralert.present();
});
pushObject.on('error').subscribe(error => alert('Error with Push plugin' + error));
}
cordova android version-6.3.0 push plugin version 2.1.2
pushObject.on('registration')
方法被调用,我得到设备的注册ID . 当我从firebase控制台发送通知时,我会在应用程序处于后台时在顶部栏上收到通知 . 但是当应用程序处于前台时 pushObject.on('notification')
回调未被调用 . 这里的问题是什么?