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.
Yes, you must need to add "location" key under Backround modes in Info.plist if you are using significant change location service (startMonitoringSignificantLocationChanges) to monitor user location in the background and in the app kill state.
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
And
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.