确定用户是否已拒绝CoreLocation权限 [英] Determining if user has denied CoreLocation permission

查看:228
本文介绍了确定用户是否已拒绝CoreLocation权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式确定用户是否拒绝使用其位置的权限?

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?

推荐答案

您可以使用 authorizationStatus CLLocationManager 上的类方法。这将返回 CLAuthorizationStatus ,其定义为:

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.

此外,您可以检查 locationServicesEnabled 类方法,以确定系统范围内是否启用了位置。

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

这篇关于确定用户是否已拒绝CoreLocation权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆