I have an app that uses a combination of startMonitoringForRegion:
and startMonitoringSignificantLocationChanges
to keep aware of where the user is when the app is in the background. Does this mean that I need to include the location
value for the UIBackgroundModes
key in the Info.plist
?
This is a quote from the docs:
The significant-change location service is highly recommended for apps that do not need high-precision location data. With this service, location updates are generated only when the user’s location changes significantly; thus, it is ideal for social apps or apps that provide the user with noncritical, location-relevant information. If the app is suspended when an update occurs, the system wakes it up in the background to handle the update. If the app starts this service and is then terminated, the system relaunches the app automatically when a new location becomes available. This service is available in iOS 4 and later, and it is available only on devices that contain a cellular radio.
...
An app that provides continuous location updates to the user (even when in the background) can enable background location services by including the UIBackgroundModes key (with the location value) in its Info.plist file. The inclusion of this value in the UIBackgroundModes key does not preclude the system from suspending the app, but it does tell the system that it should wake up the app whenever there is new location data to deliver. Thus, this key effectively lets the app run in the background to process location updates whenever they occur.
My interpretation of this is that the location
value for the UIBackgroundModes
key is only required if the app needs continuous location updates, like a sat nav app.
I have also tried running the app on a device without the location
value for the UIBackgroundModes
key and it continues to report significant location changes and when the a region is entered of exited.
Also, the only place that UIBackgroundModes
is mentioned in the CLLocationManager Class Reference is in the startUpdatingLocation
discussion, which I am not using.
You're right about the location
key, it's only required when your app needs high-precision location updates even when in the background. Something like Runkeeper uses this to allow it to keep tracking your location, even when you're using another app with multitasking. From the docs for iOS Keys: UIBackgroundModes
"location": The app provides location-based information to the user and requires the use of the standard location services (as opposed to the significant change location service) to implement this feature.
And
Where alternatives for running in the background exist, those alternatives should be used instead. For example, apps can use the signifiant location change interface to receive location events instead of registering as a background location app.
Region monitoring will work without the location
key. In fact, region monitoring will work without any special iOS keys being enabled.
You say that you're not using CLLocationManager
, but if you're using region monitoring, you'll have to use that class. You need to set up a location manager delegate for your app to actually get the region notifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With