@
loveour 没你想的那么麻烦。 设置一下更新距离和多长时间更新一次。就可以了。
使用的这个 API 接口,- (void)allowDeferredLocationUpdatesUntilTraveled:(CLLocationDistance)distance
timeout:(NSTimeInterval)timeout。
接口文档
/*
* allowDeferredLocationUpdatesUntilTraveled:timeout:
*
* Discussion:
* Indicate that the application will allow the location manager to defer
* location updates until an exit criterion is met. This may allow the
* device to enter a low-power state in which updates are held for later
* delivery. Once an exit condition is met, the location manager will
* continue normal updates until this method is invoked again.
*
* Exit conditions, distance and timeout, can be specified using the constants
* CLLocationDistanceMax and CLTimeIntervalMax, respectively, if you are
* trying to achieve an unlimited distance or timeout.
*
* The CLLocationManagerDelegate will continue to receive normal updates as
* long as the application remains in the foreground. While the process is
* in the background, the device may be able to enter a low-power state for
* portions of the specified distance and time interval. While in this
* state, locations will be coalesced for later delivery.
*
* Location updates will be deferred as much as is reasonable to save
* power. If another process is using location, the device may not enter a
* low-power state and instead updates will continue normally. Deferred
* updates may be interspersed with normal updates if the device exits and
* re-enters a low-power state.
*
* All location updates, including deferred updates, will be delivered via
* the delegate callback locationManager:didUpdateLocations:
*
* When deferred updates have ended, the manager will invoke the delegate
* callback locationManagerDidFinishDeferredUpdates:withError:. An error
* will be returned if the manager will not defer updates and the exit
* criteria have not been met.
*/