检测是否为我的应用启用了位置服务

时间:2011-08-28 12:35:46

标签: iphone objective-c geolocation

我正在开发我的第一个iOS应用程序,它使用用户的位置。

我知道设备会询问用户是否为应用启用位置服务,但我如何知道用户是否启用了该位置服务?

1 个答案:

答案 0 :(得分:44)

可能

[CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied

应该是答案 相关的问题是:
Checking for iOS Location Services
locationServicesEnabled test passes when they are disabled in viewDidLoad

是的,根据@albertamg的建议,如果你实施CLLocationManagerDelegate protocol

如果用户在您请求时拒绝访问位置服务,您将收到通知 请参阅locationManager:didChangeAuthorizationStatus:locationManager:didFailWithError:方法