CLLocation再次请求许可 [英] CLLocation ask again for permission

查看:136
本文介绍了CLLocation再次请求许可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我的应用程序只询问一次是否允许使用当前位置。如果用户不允许,除非他在一般设置中重置位置警告,否则不会再次询问。我想让用户有机会在应用程序中稍后授予此权限。换句话说,如果按下某个按钮,对话框应该再次出现。这可能吗?

Currently my application asks only once for permission to use the current location. If the user doesn't allow, he isn't ask again unless he resets location warning in the general settings. I would like to give the user a chance from within the app to grant this permission later. In other words, the dialog should appear again if he presses a certain button. Is this possible?

感谢您的建议。

推荐答案

新答案:
现在在iOS 8中,您可以以编程方式打开设备设置应用程序:

New Answer: Now in iOS 8 you CAN programatically open the device settings app:

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];

如果您支持早期的iOS版本并希望确保可以处理,请执行以下操作:

If you are supporting earlier iOS versions and want to make sure this can be handled, do this:

if (&UIApplicationOpenSettingsURLString != NULL) {
   NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
   [[UIApplication sharedApplication] openURL:url];
}
else {
  //Earlier iOS version
}

旧答案:
我无法强制显示原生弹出窗口(并允许用户跳转到设置页面)。

Old Answer: There is no way I know of to force the native popup to appear (and allow the user to jump to the settings page).

您可以使用以下方法确定用户是否允许您的应用程序使用位置服务:
CLLocationManager:

You can use the following method to determine if the user has allowed location services for your app: CLLocationManager:

+(CLAuthorizationStatus)authorizationStatus

你可以还可以了解位置服务是否在设备级别全局启用:
CLLocationManager:

You can also find out if location services are globally enabled at the device level or not, too: CLLocationManager:

+(BOOL)locationServicesEnabled

这篇关于CLLocation再次请求许可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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