I’d like to know if is possible to send asynchronous connections when an app is in background. The reason for this is because I need to send the user’s location (get from Core Location) to update a database in a remote server everytime the location changes, even if the app is not in foreground.
Do I have to set any permission for this? Does Apple rejects apps processing connections when app is in background?
Thanks in advance!!
iOS provides multitasking API’s i.e. even if your app is in background, some of its API’s can be accessed. These services are –
So you can definitely send location updates using
CoreLocationwhen the app is not in foreground.This link – iOS multitasking has code to start your service when app in background. Step by step instructions
NSTimerin the background by usingUIApplication:beginBackgroundTaskWithExpirationHandler:xtime is smaller thanUIApplication:backgroundTimeRemainingit does works just fine, in casexis larger, the location manager should be enabled (and disabled) again before there is no time remaining to avoid the background task being killed. This does work since location is one of the three allowed types of background execution.SOURCE – How do I get a background location update every n minutes in my iOS application?