Background user location when app is terminated/suspended Background user location when app is terminated/suspended ios ios

Background user location when app is terminated/suspended

You can register for regions in 500m area and register for notification region notification in them. When it reaches one if them, your app is launched in background. Then, re-register for new ones keeping that location at center.

enter image description here

From Apple's Documentation:

Apps that support background execution may be relaunched by the system to handle incoming events. If an app is terminated for any reason other than the user force quitting it, the system launches the app when one of the following events happens:

For location apps:

  • The system receives a location update that meets the app’s configured criteria for delivery.

  • The device entered or exited a registered region. (Regions can be geographic regions or iBeacon regions.)

In case you need location updates frequently but still want to save battery life, try this -

  1. Add necessary permissions for using location in background.
  2. Start the updates using startUpdatingLocation
  3. Start deferring updates when in background using allowDeferredLocationUpdatesUntilTraveled:timeout: Specify time and distance filters in this method.
  4. Make sure you read the docs here and specify all the properties correctly to get it working.

The only solution is to use background mode with CoreLocation. If your app requires iOS 8, the system will relaunch your app, even if force quit by the user. This is documented in Apple Docs:

In most cases, the system does not relaunch apps after they are force quit by the user. One exception is location apps, which in iOS 8 and later are relaunched after being force quit by the user. In other cases, though, the user must launch the app explicitly or reboot the device before the app can be launched automatically into the background by the system.