I want to add a feature to our application that let’s a user know when he/she is within proximity of a set location (using GPS to get their coordinates).
I don’t want the GPS on all of the time because the radius is quite large (maybe up to 5 miles) so the user doesn’t exactly have to be notified right after entering the zone.
I would like a timer running in the background that fires a method every 5 minutes or so to turn on the GPS, get an accurate location reading of where the user is, and then turn off the GPS (of course, notifying the user if they are within range). How can I have a part of my application running in the background on a timer?? I don’t want the app to have to be on and visible the entire time. Is this possible on a 3G iPhone and not only the iPhone 4 and 4S???
Thanks a lot!!
It depends on the os, not the model. You can keep the app alive in the background by starting core location in your background task expiration handler which will continue the apps execution but only in 5.0 and above. Make sure you use NSRunLoopCommonModes for your timer to prevent interruptions