3

I have registered for remote notifications fine

I have the deviceToken, the server is using it, it's sending messages to my test user, and when the app is in foreground I breakpoint and receive incoming remote notifications.

But when the app is backgrounded, nothing.

SSL certs signed for dev and prod. Currently, I using the dev push.pem with sandboxed APNS address, against a iOS Developer signed profile.

Help?

Fang Chen
  • 236
  • 2
  • 14
  • See my answer here: http://stackoverflow.com/a/31450953/594074 – Baris Akar Sep 23 '15 at 09:08
  • possible duplicate of [didReceiveRemoteNotification not working in the background](http://stackoverflow.com/questions/31450403/didreceiveremotenotification-not-working-in-the-background) – Baris Akar Sep 23 '15 at 09:09

3 Answers3

3

Set the "Remote Notification" on in your app Capabilities as shown in the figure below:

Remote Notification

Hope this might be helpful.

Karlos
  • 1,653
  • 18
  • 36
2

Do as @karlos Suggest. And also add "content-available":1 in your payload because by providing this key with a value of 1 will indicate that new content is available. Including this key and value means that when your app is launched in the background or resumed, application:didReceiveRemoteNotification:fetchCompletionHandler: is called.

For more information follow this link.

ajay_nasa
  • 2,278
  • 2
  • 28
  • 45
2

Thank you for the suggestions but the problem has been resolved, it was an issue with the server payload

1 Our server is using a third party push notification library 2 this library was wrapping our json payload

Our payload

aps: { alert: ...,

With another layer

aps: { alert: { aps: { alert: ...,

Apple's APNs wasn't complaining one bit because the json is not malformed and totally legitimate and within size

I found this out after looking at the incoming notifications, while my iphone was run from/connected to Xcode.

Human error, server side

Fang Chen
  • 236
  • 2
  • 14