I've been trying to figure out how to get the user's location when the app is terminated like how the app Moves does it. The only way I know of doing so is with Significant Location Changes. However with significant location changes, the app only gets woken up either every 500 meters and only if it has been around 5 minutes past the last update.
According to Apple:
Apps can expect a notification as soon as the device moves 500 meters or more from its previous notification. It should not expect notifications more frequently than once every five minutes. If the device is able to retrieve data from the network, the location manager is much more likely to deliver notifications in a timely manner.
In the Moves app, even with the app is terminated, it is able to retrieve the user's location very accurately without having much drainage in battery. It also doesn't seem to have background location turned on as it's reason in the battery usage list only shows "Background Activity". So I'm wondering how an app like Moves is doing this. Any help would be great! Thanks.
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.
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 -
startUpdatingLocation
allowDeferredLocationUpdatesUntilTraveled:timeout:
Specify time and distance filters in this method. 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