Determining if user has denied CoreLocation permis

2019-02-07 02:56发布

Is it possible to determine programmatically that a user has denied permission to use their location?

Secondly, if a user has denied permission, is it possible to re-prompt the user?

2条回答
太酷不给撩
2楼-- · 2019-02-07 03:15

You can determine your authorization status using the authorizationStatus class method on CLLocationManager. This returns a CLAuthorizationStatus which is defined as:

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

The system will prompt the user to authorize your application if the authorization status is undetermined when you attempt to start the location manager.

Additionally, you can check the locationServicesEnabled class method to determine if location is enabled system wide.

查看更多
3楼-- · 2019-02-07 03:15

Additionally - If locationServicesEnabled returns NO and you attempt to start location services anyway, the system will prompt the user to confirm whether location services should be reenabled.

查看更多
登录 后发表回答