I'm working on an application that should be able to collect location data while the application is in background.
To allow this, I have done the following:
In the project settings, under the
Capabilities
tab I have tickedLocation updates
.I have set the
NSLocationAlwaysUsageDescription
key in the ApplicationsInfo.plist
and have assigned an appropriate string value.- I have configured an instance of
CLLocationManager
like so:locationManager.activityType = .Fitness
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.pausesLocationUpdatesAutomatically = false
- Before beginning location collection I call
locationManager.requestAlwaysAuthorization()
, I have the appropriate delegate callbacks to handle any error. - lastly, I call
locationManager.startUpdatingLocation()
When running the application on the simulator, I get a print out of the location updates, and the application's badge is also updated with the number of locations collected, but when running the applications on an actual device, after sending the app in the background, location updates are shortly stopped from being handled by the app (I know this as the badge stops updating).
Am I missing some sort of device specific configuration?