针对特定应用启用了位置服务?

bec*_*oan 3 iphone ios4

有没有办法确定是否已针对特定应用程序禁用了位置服务?问题是[CLLocationManager locationServicesEnabled]返回YES,即使已针对特定应用程序禁用了位置服务...

tab*_*ber 10

如果您的目标是iOS 4.2及更高版本,请使用 [CLLocationManager authorizationStatus]

它将返回以下CLAuthorizationStatus值之一,它们基本上只是整数:

typedef enum {
   kCLAuthorizationStatusNotDetermined = 0,
   kCLAuthorizationStatusRestricted,
   kCLAuthorizationStatusDenied,
   kCLAuthorizationStatusAuthorized
} CLAuthorizationStatus;
Run Code Online (Sandbox Code Playgroud)

在文档中搜索"CLLocationManager"以获取更多信息.


Aar*_*ers 5

实现位置管理器的委托时,应该实现didFailWithError.如果用户不允许访问位置,那么您将收到相应的错误

Apple文档状态: 如果用户拒绝您的应用程序使用位置服务,则此方法会报告kCLErrorDenied错误.收到此类错误后,您应该停止位置服务.