My app requires to update location continuously, even if app is killed or removed from background. It works fine in foreground and even in background mode.but not working wh
I hope this might help you. Your app can be awaken when it is terminated by some reason (Memory pressure).
But there's limitation on background location update when app is terminated.
This is note from Apple's Location and Map programming guide.
If your app is terminated either by a user or by the system, the system doesn't automatically restart your app when new location updates arrive. A user must explicitly relaunch your app before the delivery of location updates resumes. The only way to have your app relaunched automatically is to use region monitoring or significant-change location service. However, when a user disables the Background App Refresh setting either globally or specifically for your app, the system doesn't relaunch your app for any location events, including significant change or region monitoring events. Further, while Background App Refresh is off your app won't receive significant change or region monitoring events even when it's in the foreground.
So to receive location update in background, you should turn on Background App Refresh
setting for your app (You can see the setting in Settings/Your App/Background App Refresh
in your iPhone.)
Also only significant changes will be delivered when app is terminated and like location changes you mentioned here (I mean kCLLocationAccuracyBest
) probably will not wake your app.
Further more, you should restart the location manager in your app delegate
s application:didFinishLaunching:withOptions
method to retrieve next significant location changes. Also make sure return as soon as possible when location is retrieved in background mode or use background task mechanism to make app working more a few minutes in background. (2~3 mins).
Its possible, but you'll have to jump through a few hoops. The only way to send location updates when killed is by using Region Monitoring (https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html). When setup up, your app would be opened by the OS then you have a few seconds to process information before the app is killed. Its enough time to send location updates to your server/local storage. There is also another API called CLVisit, however, its completely controlled by the operating system and not reliable.