0

I'm trying to achieve precisely this: have a method called when the user hasn't moved for a defined amount of time, even if the app is in background, and with a reasonable power consumption.

This could be easily done if I didn't care about the power issue, so i'm not very interested in solutions like setting up a location manager refreshing very often.

I found a way to do exactly the opposite, like determining when the user leaves a place, but I can't seem to find what i want to do.

If my case is not precise enough feel free to ask for more details.

Thanks!

dvkch
  • 1,079
  • 1
  • 12
  • 20

1 Answers1

0

You need to execute a repetitive NSTimer on background thread, check the age of last GPS update and take action appropriately.

For further optimisations you may need to disregard certain location-updates based on lat/lon, timestamp, speed. Tip: Speed/Course should be -1 when user is static (but these values could be -1 when user is moving).

Zee
  • 1,865
  • 21
  • 42
  • I ended using geofences that i setup around user's location, and a timer to know if he has crossed it, but the GPS precision isn't always great so it doesn't always work, in brief: there is not good solution :( i'll mark yours as accepted though, you took the time to look into it, thx! – dvkch Sep 24 '14 at 19:55
  • As per my experience, GeoFence relies on Wifi/Cell change events, for me also they are they are not a good solution to that problem. If time is not important factor you activate GPS for n minutes after m minutes. see http://stackoverflow.com/questions/18263047/cllocationmanager-geo-fencing-startmonitoringforregion-vs-startmonitoringforsi/18446695#18446695 – Zee Sep 25 '14 at 15:13