location update auto pause iOS

本小妞迷上赌 提交于 2020-01-14 22:54:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!