I have this problem regarding APNS in my iPad 2 running iOS 8.1 . I searched on Google for a few days and tried every solution that I can find. However I cant seem to solve this problem.
What I did:
- Enabled capabilities: remote-notification, background fetch
- I have "content-available = 1" in the aps payload.
- I used NSLog() in didReceiveRemoteNotification:fetchCompletionHandler so I can see in device log clearly if the method is triggered
What I want to do:
I want to perform network request when I receive the APNS in background. I believe I can handle that part well using beginBackgroundTaskWithExpirationHandler and stuff. However, going down the investigation I found that the problem is due to didReceiveRemoteNotification:fetchCompletionHandler not been run when app is in background state.
Problem:
didReceiveRemoteNotification:fetchCompletionHandler can trigger when app is in foreground. But it is ONLY triggered in background when xcode is still debugging the app. Which means if I unplug the cable (the debugging session is over), it cannot trigger anymore. Same thing if I replug it back in. No response.
However, at the same time, I can still receive APNS with alert body and sound (although the method is still not triggered) as I see in the Device Log.
I tried every combination of "silent" push notification: sound = "", alert = "", etc. But nothing seems to work. Any help from the pros here?
Thank you.