0

I am using GCM on iOS. Everything just works fine until application went to background and I can't receive push, I implemented Google sample code and also implement didReceiveRemoteNotification:fetchCompletion and didReceiveRemoteNotification. I use this struct to send push message and this works:

    {
      "to" : "ccoU4..d.",
      "data": {
          "message" : {
              "test" : "Test"
          }
      }
    }

but I change it to this for waking device from background and I get NotRegistered error :

    {
        "to":".....",
        "content_available":true,
        "priority": "high", // Add this field corresponds to 10 for APNS
        "notification": {
                "title":"my title",
                "body":"my body",
                "sound":"default"
        } 
    }

that is so strange, Google's documentation says I can add these two columns but it doesn't work

Artem Mostyaev
  • 3,874
  • 10
  • 53
  • 60
  • I hope you are trying to use "content-available" it should be inside "aps".Check out this guide for remote notification payload for iOS https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html. – Sanman Jun 20 '16 at 09:45
  • @sanman i think `content-available` filed is for APN and i couldn't see this field in google's documentation.however there was a `content_available` field and when i put it there it throws NotRegistered error for me – alireza abdolalipoor Jun 20 '16 at 10:36
  • Heya, this [SO thread](http://stackoverflow.com/questions/31109514/making-gcm-work-for-ios-device-in-the-background) might help. Check it out friend :) – ReyAnthonyRenacia Jun 21 '16 at 06:31
  • @noogui i read all the responses on stackoverflow,when i change struct of my json that sent to gcm,it throws `NotRegistered` error – alireza abdolalipoor Jun 22 '16 at 09:08
  • Ok so it seems you've moved on to the next problem. This "Device Not Registered" error is a growing concern. Kindly check this [Github post](https://github.com/google/gcm/issues/49). It might offer some insight. – ReyAnthonyRenacia Jun 24 '16 at 01:50
  • Try also to look into [GCM HTTP Connection Server](https://developers.google.com/cloud-messaging/http#response) guide. It says that "If it is NotRegistered, you should remove the registration ID from your server database because the application was uninstalled from the device, or the client app isn't configured to receive messages." – ReyAnthonyRenacia Jun 24 '16 at 03:03
  • @noogui i looked up to your links,but nothing useful came up,i can assure you this is a bug from GCM itself , i even don't use database ,its an iOS device and postman for request, device configuration is all set and i get token from GCM after 2 request it throws `NotRegistered` – alireza abdolalipoor Jun 25 '16 at 05:44

0 Answers0