ios significant location changes, UIBackgroundModes and app launch after suspend

990 Views Asked by At

EDIT:

My app should recognized significant location changes and region changes when in foreground, in background and when suspended. This works, when allowsBackgroundLocationUpdates is set to true and UIBackgroundMode "location" is set in Info.plist

Apple writes on app review, that my app has no feature that needs continuous location tracking and that UIBackgroundMode "location" is not needed. And apple is right, because I only need the significant/region detection. So we should disable UIBackgroundMode "location". But when I do so, I have to set allowsBackgroundLocationUpdates to false and relaunch is disabled.

How do I enable relaunch on significant location changes and region monitoring without setting UIBackgroundMode "location"?

What I found in the Apple Documentation:

Discussion

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; you use this property to enable and disable the behavior based on your app’s behavior. For example, you might set the value to true only after the user enables features in your app where background updates are needed.

When the value of this property is false, apps receive location updates normally while running in either the foreground or background based on its current authorization. Updates stop only when the app is suspended, thereby preventing the app from being woken up to handle those events.

The default value of this property is false. Setting the value to true but omitting the UIBackgroundModes key and location value in your app’s Info.plist file is a programmer error.

Update 16.10.2017

I just tested this on a real phone. And with allowsBackgroundLocationUpdates set to false, the app still relaunches from suspend on sdk11, ios 10.3.1. This is not like in the docs, but my problem is solved for now. –

0

There are 0 best solutions below