问题
I'm building an iOS app using phonegap. I'm trying to get iOS to update its current position to my app when the app runs in the background. I've registered the location updates background mode however it's not reliable. After some research, I believe that iOS is automatically pausing the location updates. There's an attribute in CLLocationManager called 'pausesLocationUpdatesAutomatically' that I think is responsible for this behavior.
The following declaration is from CLLocationManager.h in CoreLocation.framework
/*
* pausesLocationUpdatesAutomatically
*
* Discussion:
* Specifies that location updates may automatically be paused when possible.
* By default, this is YES for applications linked against iOS 6.0 or later.
*/
@property(assign, nonatomic) BOOL pausesLocationUpdatesAutomatically __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);
Any insight on how to disable this feature?
Much appreciated.
Shu
回答1:
You should set this property to NO like this:
_locationManager.pausesLocationUpdatesAutomatically = NO;
来源:https://stackoverflow.com/questions/19887571/location-update-auto-pause-ios