Reputation: 2764
I would like to be able to make location and app state requests when the app is in the background. I know that you can have different background modes registered for the app.
Is it possible for my web server to send a push notification to an iOS device and the device in turn sends and NSURLConnection sending the current location data and any other state data as part of the body of the request? In essence I am turning the iOS device into a web server that is sending a response to my server in order to report that data to other users.
Upvotes: 1
Views: 481
Reputation: 1201
With iOS 7 Apple introduced the ability for push notifications to trigger a background fetch. So it is possible for your server to send a push notification to the app and then app do background work as a result, with no user interaction.
See the section titled Background fetch on remote notification on this post.
Also you can use GPS in the background, you just need to specify the location updates
background mode.
Upvotes: 1
Reputation: 8066
Push notifications can't do anything unless user taps them and open the app.
However you can call a web service and fetch/send data to a server in a timely manner using background fetch in iOS 7 or later. Push notifications are not required to do this.
But it's not possible to access things like GPS data which requires the app to be in foreground mode. All you can do is send the last known location using background fetch.
Upvotes: 0