Periodically 'ping' the iPhone GPS?
I'm trying to create an app similar to TravAlert which apparently 'pings' the GPS periodically to figure out where you are. Unfortunately, I'm having a heck of a time figuring out how to do it.
I can't use an NSTimer to fire off the GPS checks because NSTimer doesn't run in the background (which this app presumably must do). I can't use Local or Push notifi开发者_JS百科cations as "timers" because they automatically come with a notification and I don't want the use to know every single time that the GPS was queried.
I also tried using CoreLocation's startMonitoringSignificantLocationChanges and that works to a degree, but I can just see the case where the user happens to be in a region of poor cell service (apparently startMonitoringSignificantLocationChanges uses cell tower triangulation as a means of determining location) and thus the app fails to fire.
Any idea how TravAlert does it?
Thanks!
P.S. I'm not trying to rip off TravAlert by making a better app - this is for a college class and unfortunately neither my professor or anybody else in my class has the faintest idea as to how to replicate TravAlert's GPS "ping".
startMonitoringSignificantLocationChanges
is the right choice for your app. You can get finer detailed location whilst your app is running. The other option to run the GPS in the background is intended for navigation apps hooked up in a car due to high power consumption.
精彩评论