Can I send user's current location to server, when app is in background?

core-location, ios, ios7, iphone

Solution

You can since iOS7. You basically need to ask for two background states: location and fetch. In your app you'll register for gps location changes, and store them every time your callback is called. Then you'll register for:

 application:performFetchWithCompletionHandler:

This is usually used to download files in the background, but you can use it to POST your data to a webserver. Just note that you don't have control on the frequency of this call. To test this you can force a fetch operation in the iOS simulator, from the Xcode Debug menu. I was able to track the user position successfully this way. You can find more info in the Apple doc and you'll find a tutorial on the background fetch here

Problem

Can I send user's current location to server when app is in background. For example: In my app i want to store the user's current location in every 2min and then send his current location to server. Can I do this when the app is in background? Can I send location updates to the server in background mode and how?

Original source