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設置的通知... 有什麼建議嗎? 謝謝你的幫助。