I am trying to send push notifications to my iOS application using GCM. The application does not receive a notification when it is in the background, but it runs when it is in the foreground. I tested push notifications using a PHP script that sends a message directly to APNS and runs in the background.
JSON sent to GCM: (I am sending it from the client for testing)
{ "to" : "token...", "notification" : { "title": "GCM TITLE", "body" : "FROM GCM", "badge": "1", "sound": "default" } }
Doesn't work : User information received from GCM in didReceiveRemoteNotification:
Notification received: [aps: { alert = { body = "FROM GCM"; title = "GCM TILE"; }; badge = 1; sound = default; }, gcm.message_id: 123...]
Q : User information received when sending with a PHP script (I also added message_id in JSON to find out if this is a problem)
Notification received: [aps: { alert = { body = "FROM PHP"; title = "PHP TITLE"; }; badge = 2; sound = default; }, gcm.message_id: 123...]
I tried adding content_available to JSON with various combinations, but didn't help, Content-Type and Authorization request headers are also set:
Content-Type:application/json Authorization:key=...
source share