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?
Thanks for your advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
[CLLocationManager locationServicesEnabled]
只是告诉您设备上是否启用了位置服务。根据此文档。
如果结果是 kCLAuthorizationStatusDenied,
[CLLocationManagerauthorizationStatus]
将返回其中之一,
您可以通过将用户发送到 settings.app 来告诉用户允许使用位置服务
[CLLocationManager locationServicesEnabled]
just tells you if the locations services are enable on the device.according to this document.
[CLLocationManager authorizationStatus]
will return one of these
if the result is
kCLAuthorizationStatusDenied
your could tell the user to allow the usage of the location services by sending him to the settings.app新答案:
现在,在 iOS 8 中,您可以以编程方式打开设备设置应用程序:
如果您支持早期的 iOS 版本并希望确保可以处理此问题,请执行以下操作:
旧答案:
据我所知,没有办法强制显示本机弹出窗口(并允许用户跳转到设置页面)。
您可以使用以下方法来确定用户是否允许您的应用使用位置服务:
CLLocationManager:
您还可以了解位置服务是否在设备级别全局启用:
CL位置管理器:
New Answer:
Now in iOS 8 you CAN programatically open the device settings app:
If you are supporting earlier iOS versions and want to make sure this can be handled, do this:
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).
You can use the following method to determine if the user has allowed location services for your app:
CLLocationManager:
You can also find out if location services are globally enabled at the device level or not, too:
CLLocationManager: