Issue
Using CAPACITOR
and IONIC
Everything is Perfectly Works on Android but in IOS i am having Following Error:
APNS device token not set before retrieving FCM Token for Sender ID 'mySenderId'. Notifications to this FCM Token will not be delivered over APNS.Be sure to re-retrieve the FCM token once the APNS device token is set.
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 3.2.2
@capacitor/core: 3.2.2
@capacitor/android: 3.2.2
@capacitor/ios: 3.2.2
Installed Dependencies:
@capacitor/cli: 3.2.2
@capacitor/core: 3.2.2
@capacitor/android: 3.2.2
@capacitor/ios: 3.2.2
I can see FCM Token in my Xcode
Logs but notification are not working.
References:
Solution
The solution is to register for APNS token before FCM token.
PushNotifications.requestPermissions().then((permission) => {
if (permission.receive == "granted") {
// Register with Apple / Google to receive push via APNS/FCM
if(Capacitor.getPlatform() == 'ios'){
PushNotifications.register().then((res)=>{
console.log('From Regisiter Promise', res)
})
PushNotifications.addListener('registration', (token: Token)=>{
FCM.getToken().then((result) => {
this.remoteToken = result.token;
}).catch((err) => console.log('i am Error' , err));
})
}else{
FCM.getToken().then((result) => {
this.remoteToken = result.token;
}).catch((err) => console.log('i am Error' , err));
}
} else {
// No permission for push granted
alert('No Permission for Notifications!')
}
});
Answered By - Najam Us Saqib
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.