Location tracking stops after a while when app is in the background
desiredAccuracy property of the location manager object
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
You can use one of the
By default, standard location updates on iOS devices run with an accuracy level of best. Change these settings to match your app’s requirements. Otherwise, your app will unnecessarily waste energy.
pausesLocationUpdatesAutomatically property of the location manager object to
self.locationManager.pausesLocationUpdatesAutomatically = true
For apps that have in-use authorization, a pause to location updates ends access to location changes until the app is launched again and able to restart those updates. If you do not wish location updates to stop entirely, consider disabling this property and changing location accuracy to
kCLLocationAccuracyThreeKilometerswhen your app moves to the background. Doing so allows you to continue receiving location updates in a power-friendly manner.
Allow background updates
allowsBackgroundLocationUpdates property of the location manager object to
self.locationManager.allowsBackgroundLocationUpdates = true
Apps that want to receive location updates when suspended must include the UIBackgroundModes key (with the location value) in their app’s Info.plist file and set the value of this property to true. The presence of the UIBackgroundModes key with the location value is required for background updates
Specify an Activity Type
activityType property to let Core Location know what type of location activity your app is performing at a given time
self.locationManager.activityType = .automotiveNavigation
You can use one of the
On supported devices with GPS hardware, you can let the location manager defer the delivery of location updates when your app is in the background. For example, a fitness app that tracks the user’s location on a hiking trail can defer updates until the user has moved a certain distance or a certain period of time has elapsed.
After searching for references (talking about any limitation), I assume that Apple Core Location Best Practices video session could be useful! at
06:53 talking about standard location in the background:
furthermore, Core Location won't take any action to ensure your app continues to run, so if you have background run for some reason and you decide to start a location session you might get some updates, but you might also get suspended before you receive all information that you hope to receive...
Actually, I faced this issue before, -as a workaround- the core location was used to keep tracking the location of the user to do unrelated functionality to its location -which is uploading files-, but this workaround didn't work since iOS 9 has been released; I even posted a question referring to this issue.
However, it seems your case is not identical to what I faced, if you are aiming to:
... creates local notification for every time location is updated.
then you might need to follow the approach of integrating with User Notification Framework - UNLocationNotificationTrigger:
The geographic location that the user must reach to enable the delivery of a local notification.
It is also mentioned in the video session (
Probably, this is could be not what are you looking for, but since we have no guarantee that the background execution will continue running, you might -somehow- find a way to integrate it in your app to achieve the desired functionality.
Update for iOS 11:
You might need to check this answer for the proper way to request the location access.