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

时间:2010-10-20 01:49:01

标签: iphone ios4

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

2 个答案:

答案 0 :(得分:10)

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

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

typedef enum {
   kCLAuthorizationStatusNotDetermined = 0,
   kCLAuthorizationStatusRestricted,
   kCLAuthorizationStatusDenied,
   kCLAuthorizationStatusAuthorized
} CLAuthorizationStatus;

在文档中搜索“CLLocationManager”以获取更多信息。

答案 1 :(得分:5)

实现位置管理器的委托时,您应该实现didFailWithError。如果用户不允许访问位置

,那么您将收到相应的错误

<强> Apple Documentation States: 如果用户拒绝您的应用程序使用位置服务,则此方法会报告kCLErrorDenied错误。收到此类错误后,您应该停止位置服务。

相关问题