如何检查GPS权限是否已开启或关闭以用于iOS中的特定应用程序?

Joh*_*elp 3 iphone gps objective-c ios

使用BOOL locaService = [CLLocationManager locationServicesEnabled];

它将返回一般GPS服务的布尔值,我们如何检查服务是否打开或关闭特定的应用程序.

小智 9

[CLLocationManager authorizationStatus]返回一个CLAuthorizationStatustypedef为kCLAuthorizationStatusNotDetermined, kCLAuthorizationStatusRestricted, kCLAuthorizationStatusDenied,或的kCLAuthorizationStatusAuthorized.

kCLAuthorizationStatusAuthorized 意味着你可以使用GPS,其他任何意味着你不能.

(kCLAuthorizationStatusDenied意味着他们已禁止您,kCLAuthorizationStatusRestricted意味着由于家长控制而无法使用, kCLAuthorizationStatusNotDetermined意味着用户尚未响应"允许此应用查看我的位置?"提示.)