I am trying to send notifications to an IOS device using Firebase Cloud Messaging - every IOS project in the Firebase Console has a valid APNs P8 Auth Key, freshly generated from the Apple developer account for this purpose.
I’m using this approach:
curl -X POST \
https://fcm.googleapis.com/fcm/send \
-H 'Authorization: key=<My Key>' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"to": "<Device Token>",
"notification": {
"title": "Push Notification Test to IOS",
"body":"Push Notification Test to IOS"
},
"data": {
"message": "Push Notification Test to IOS"
}
}'
This results in the following error from FCM:
{
"multicast_id": <Id>,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "InvalidApnsCredential"
}
]
}
If I remove the "notification" block from the message, FCM responds with a success, but nothing is received on the device.
I can send and receive notifications using the above example message to Android devices just fine.
The FCM documentation suggests that when a "notification" block is included, FCM attempts to send via APNs when the token is for an IOS device:
If a notification payload is provided, or the content_available option is set to true for a message to an iOS device, the message is sent through APNs, otherwise it is sent through the FCM connection server.
What I have tried:
- Refreshing the tokens
- Waiting 24 hours for tokens to propagate in APNs and FCM server environments
- using P12 certificates
- using P8 certificates
- ensured the IOS app is allowing notifications in Xcode
- ensured the Apple Developer account has the app as allowing notifications
- ensured the Bundle Ids are correct in the plist, FCM and Apple account
- tried both the FCM legacy key and server key