1

for an app that is part of a scientific study I have to implement location tracking (the users who take part in the study know this and are willing to supply this data). The two premises for this app are:

  1. track the user's location with the highest accuracy possible while he/she is on the move
  2. use as little power as possible so that users don't feel the need to shut down the app (turn off location services for it), while they aren't using it

I know these two requirements normally exclude each other :) So the general question is "What would be the best strategy to meet in the middle here?"

My thoughts were to monitor as usual with the highest accuracy possible while location changes keep coming in. If we detect that the delta between theses location updates become almost 0 over a certain period of time, we would assume that the user is not "on the move" anymore and would switch to region monitoring (with a radius of e.g. 40m). Once the user exits that region we'd switch back to regular location monitoring.

So two questions:

  1. Can you tell me if the proposed approach will work for an app that is running in the background?
  2. Have you maybe implemented something similar and know if it really saves a lot of battery power?

Regards,

Sebastian

Sebastian
  • 2,889
  • 4
  • 34
  • 37

1 Answers1

0

My thoughts were to monitor as usual with the highest accuracy possible while location changes keep coming in. If we detect that the delta between theses location updates become almost 0 over a certain period of time, we would assume that the user is not "on the move" anymore and would switch to region monitoring (with a radius of e.g. 40m). Once the user exits that region we'd switch back to regular location monitoring.

Using region monitoring to re-engage the location monitoring has a few draw backs, that I have found:

If you set up a region for the user's current location, then wait for -didExitRegion to fire, you're reliant upon the system's default radius cushion, (probably 200m) and some time (probably 20 sec) after they cross out of their boundary before you'll get the message. If accuracy is your main goal, you're likely to loose a lot of data points in between when region monitoring started and when you cross out of the region. Is that acceptable for your needs?

So, to answer your questions:

Can you tell me if the proposed approach will work for an app that is running in the background?

You should not have any trouble running this type of thing in the background. Both location monitoring and region monitoring work when an app is backgrounded, provided you've set it up to do so. Also, to ensure Region Monitoring works on iOS 7 you must have Background App Refresh turned on for your app. That tripped me up.

Have you maybe implemented something similar and know if it really saves a lot of battery power?

In our experience the battery savings were not noticeable. Region Monitoring can be a battery drain that's just as significant as the high accuracy location updates because it uses all kinds of hardware to do it's thing. So pick your poison. Apple's recommendation for saving battery is and always has been to use the significant change location service. It gives you good location data just not as often.

Community
  • 1
  • 1
Aaron
  • 7,055
  • 2
  • 38
  • 53