decision-labs / gcm

A gem that helps developers send data from ruby backend servers to their Mobile applications on devices via Google Cloud Messaging (GCM).
MIT License
385 stars 61 forks source link

Problem with iOS notifications when the app is in the background #27

Open aozbayra opened 9 years ago

aozbayra commented 9 years ago

I am using this gem to set up my iOS app receive notifications from GCM. My app does indeed receive notifications when its active(on the foreground), however when its not active, it does not receive anything unless I make it active again. From what I read through multiple sources, I must send a this key value pair within my JSON post request: "content_available" : "true" but when I do so I receive an internal server error although I have the APNs certificate. Any thought on why this gem is not working when my app is on background and its indeed working when its active?

kashif commented 9 years ago

great question @aozbayra i'll investigate

aried3r commented 8 years ago

I'm not using this gem specifically, but we recently did this at work (using the PushKit Framework, if that's useful to you).

First of all, content_available has to be a boolean, as in

{
  "content_available": true
}

and not

{
  "content_available": "true"
}

which would result in an error message from the GCM servers.

Also, if you want your app to be woken up, even if the app was force quitted or after a device restart, the priority of the GCM notification has to be "high" (which corresponds to iOS' 10 priority). I'm not sure what you have to do on the app side to make this possible, I'd have to ask the developer who implemented this.