0
我试图推送通知与邮递员和Firebase,但我有一些iOS通知问题。 我猜Firebase配置是正确的,因为我之前有一个无效的apns证书错误,现在我得到了成功。离子2推ios不会到达设备
所以,这是我的邮差:
这是我使用
initPushNotification() {
if (!this.platform.is('cordova')) {
console.warn("Push notifications not initialized. Cordova is not available - Run in physical device");
return;
}
const options: PushOptions = {
android: {
senderID: "883847118563"
},
ios: {
senderID: "883847118563"
},
windows: {}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('registration').subscribe((data: any) => {
console.log("device token ->", data.registrationId);
localStorage.setItem("pushToken", data.registrationId);
let alert = this.alertCtrl.create({
title: 'device token',
subTitle: data.registrationId,
buttons: ['OK']
});
alert.present();
});
pushObject.on('notification').subscribe((data: any) => {
console.log('message', data.message);
if (data.additionalData.foreground) {
let confirmAlert = this.alertCtrl.create({
title: 'New Notification',
message: data.message,
buttons: [{
text: 'Ignore',
role: 'cancel'
}, {
text: 'View',
handler:() => {
// this.nav.push(DetailsPage, {message: data.message});
}
}]
});
confirmAlert.present();
} else {
// this.nav.push(DetailsPage, {message: data.message})
let alert = this.alertCtrl.create({ // o que fazer quando clica na app
title: 'clicked on',
subTitle: "you clicked on the notification!",
buttons: ['OK']
});
alert.present();
console.log("Push notification clicked");
}
});
pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));
}
代码这是我的云设置:
const cloudSettings: CloudSettings = {
'core': {
'app_id': 'bde818c3' // ID da app @https://apps.ionic.io/apps/
},
'push': {
'sender_id': '883847118563',
'pluginConfig': {
'ios': {
'badge': true,
'sound': true
},
'android': {
'iconColor': '#ff0000'
}
}
}
};
请注意,这里的一些代码仅用于测试。 因此,我的Android收到没有问题的通知,但iPad无法收到它。我已经给应用程序的permition,以获得有关ios设置的通知... 有什么建议吗? 谢谢你的帮助。