Issue
I'm trying to add push notifications to my Ionic app using FCM and running into issues with IOS, (android works as intended). Before marking this as a duplicate, Ive tried the solutions from the other similar questions but it didnt help.
In the firebase console I have set the team Id, App id as well as uploded the APNS p5 generated by apple to my console as well.
And finally, the latest plist file to my app's root. From xcode, I can see the certificate has push notifications enabled too and the app asks for that permission for it as well. After that I got the device notification id and tested it via the console as well as the api endpoint but I keep getting the "InvalidApnsCredential" error. I did the steps from few other questions from here but had no luck. I cant seem to get it working, below is a few snippets of my code
this.platform.ready().then(() => {
this.fcmService.getToken().then(resp=>{
this.httpService.sendToken(resp)
.subscribe(res => {
console.log(res)
});
console.log(resp)
});
});
And the body of the api post request
Endpoint: https://fcm.googleapis.com/fcm/send
Body:
{
"notification":{
"title":"Ionic 4 Notification",
"body":"This notification sent from POSTMAN using Firebase HTTP protocol",
"sound":"default",
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
},
"data":{
"landing_page":"second",
"price":"$3,000.00"
},
"to":"IOS_DEVICE_NOTIFICATION_ID",
"priority":"high",
"restricted_package_name":""
}
The code and api endpoint seems correct as it works for Android. Is there anything im missing to get it working?
Solution
So, this may not be exactly the answer that youre looking for but, for me everything worked fine after i recreated the app on ios. Common issues include - trying to send a notification before the client gives premission - sending notifications using older IDs (yes they change sometimes) - package name mismatch between your app and ios app
Answered By - Hunt3R
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.