简体   繁体   中英

Location Services enabled for specific app?

Is there any way to determine whether location services have been disabled for a specific app? The problem is that [CLLocationManager locationServicesEnabled] returns YES even if location services have been disabled for a specific app...

If you're targeting iOS 4.2 and above, just use [CLLocationManager authorizationStatus]

It will return one of the following CLAuthorizationStatus values which are basically just integers:

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

Search the docs for "CLLocationManager" for more info.

When you implement the delegate for location manager, you should be implementing didFailWithError. In there you will get the appropriate error if the user did not allow access to location

Apple Documentation States: If the user denies your application's use of the location service, this method reports a kCLErrorDenied error. Upon receiving such an error, you should stop the location service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM