0

iOS: How to use location tracking during predefined time period while saving battery life?

I need to activate location tracking during predefined time periods (does not matter if app in background or foreground) and need to be sure that battery life is not impacted too much?

PS: Please not that running location in background with tracking significant changes does not suits because it gives you location after 10 min and only when you passed reasonable amount of distance ... so during driving 40 km I got location only 3 times that will not allow me to catch user movement near some point. If running location more often ...that drains battery upto 40 percent per 6 hours...

Rufat AA
  • 11
  • 2

1 Answers1

0

I've researched all background modes in iOS very thoroughly recently.

The only deterministic way that will allow you to do that, without location background mode are silent pushes.

You send a silent push to the user and the user returns a location.

You could also use background fetch. But it's very non-deterministic. You can't predict if it indeed will wake up your app, or not.

EDIT:

Please note, that this will not wake up the app that was forcefully terminated.

However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

michal.ciurus
  • 3,616
  • 17
  • 32
  • Hi and thanks. That sounds like a good solution! I will try it! But will it launch app if it was killed by user before? Anyway I will check that. Currently I'm using combination of background location mode and running background task that after some minutes run location updates and terminates them after some seconds... this works great for constant tracking location and assumes about 30% of battery during a day. – Rufat AA Mar 23 '16 at 12:41
  • Hi Michal! Thanks! It is working for me. Moreover I could launch background task execution and background location or any other background modes and run tasks in background as much as I need in a loop ... So now I could manage to start from web server background location update on ios device then send user location to server and stop updating location on ios device from server on my own. and thats all managed from web server. Thanks again – Rufat AA Mar 24 '16 at 07:32