androidnotificationsapple-push-notificationsgoogle-cloud-messaging

Why is GCM and APN notifications going on some clients and not on others?


Curious case of GCM and APN in our android application.

Here the apnserverapikey and gcmserverapikey are same. The response payload for both apn and gcm is succesful, but the notification is being displayed only on ios.

We've tried to push the notification directly using the FCM_REG_ID, it won't still be sent.

Is there a way to check if the api key has expired? If yes, please share the tip.

When the logs showed mismatchsenderid, I just made gcm=apn and the issue were resolved. But I am not exactly sure what can I do when the logs say nothing except success.

We tried to clear the cache as well.

Update: Tried to Not receiving push notifications if sending "data" (but "notification" works) payloads to GCM/FCM in iOS didReceiveRemoteNotification look at this and did a short trial.

curl -X POST \
https://fcm.googleapis.com/fcm/send \
  -H 'authorization: key=gcm_server_api_key' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
    "notification": {
        "body": "kanemer akheko curl"
    },
    "to" : "device_id"
}'

I'm getting success as response.

{"multicast_id":##multicastidgoeshere##,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:message_id_goes_here"}]}

This is really getting curious to me with each step.


Solution

  • There were 2 issues.

    Not receiving push notifications if sending "data" (but "notification" works) payloads to GCM/FCM in iOS didReceiveRemoteNotification

    As told here you need to put those additional headers.

    Meanwhile the app wanted "autostart" to be on (in android devices).