I am working on an iOS tracer. It must run and receive locations even if the app is not in foreground, i.e. I use the background mode "Location updates". However, it would be fine to safe battery if possible. Especially, there is no need to receive locations if the device does not move.
- I have tried to set the
distanceFilter
onCLLocationManager
instance but it does not save power, it just reduces the number of location updates. - I cannot stop and start the location manager manually as the app would be suspended if in background.
- I have tried to use location manager with
pausesLocationUpdatesAutomatically
set toYES
(it is turned on by deafult) but if the app is in background and the location updates are paused, the app is suspended and does not wake up even if the device starts to move again.
Is there a way to save battery when I need to get location in background? The flag pausesLocationUpdatesAutomatically
is very close to what I am looking for but suspending the app in background is a show stopper for me.
What you looking for is this
ex;
So basically it will save some processing power by sending the location updates as an collection of location after specific time rather than firing the location update callback every time device register a movement.
And you can recieve the location update via the follwing callback method;