I'm using parse.com as my APNs provider for a test app I'm building. I've confirmed that push notifications are working as I have been able to successfully receive alerts when the app is in the foreground. Also, I have the remote-notification
value for the UIBackgroundModes
key specified in my plist.
In my app, I'm wanting to send a user's current location data back to my app-specific parse.com database when a push notification is received. I don't actually care about the notification payload itself, as the notification is just a means to getting a small piece of info. The app is constantly collecting data in the background and storing it in a persistent NSDictionary
.
I've put the location sending code in the application:didReceiveRemoteNotification:
method. If my app is in the foreground when I receive a notification, the method gets called. If my app is in the background, the method isn't called.
- Am I doing something wrong?
- Is it even possible to execute an API request in
application:didReceiveRemoteNotification:
when the app is in the background and the user hasn't interacted with the notification?**
EDIT: The problem persists even when I use application:didReceiveRemoteNotification:fetchCompletionHandler:
.
Note: My NSDictionary full of location data isn't empty. Also, I am not attempting to do any UI manipulation in the background - just trying to perform an API request.
content-available
flag turned on in the AppDelegate, but wasn't pushing that flag in my JSON APNs. Thanks, Alex! That fixes the problem. – Stoicism