[英]Determining if user has denied CoreLocation permission
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? 其次,如果用户拒绝了权限,是否可以重新提示用户?
You can determine your authorization status using the authorizationStatus
class method on CLLocationManager
. 您可以使用CLLocationManager
上的authorizationStatus
类方法确定您的授权状态。 This returns a CLAuthorizationStatus
which is defined as: 这将返回CLAuthorizationStatus
,其定义为:
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. 此外,您可以检查locationServicesEnabled
类方法以确定是否在系统范围内启用了位置。
此外 - 如果locationServicesEnabled返回NO并且您尝试无论如何都尝试启动位置服务,系统将提示用户确认是否应重新启用位置服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.