iOS 13检查CLLocationManager的临时授权状态 [英] iOS 13 check for provisional authorization status of CLLocationManager

查看:217
本文介绍了iOS 13检查CLLocationManager的临时授权状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据WWDC视频, https://developer.apple.com/视频/播放/ wwdc2019 / 705 / ,当您请求 AlwaysAuthorization 权限时,您只会看到 使用时,一次并且不允许 。即使您点击 使用中,委托回叫也将以 kCLAuthorizationStatusAuthorizedAlways 的形式返回。这正在按预期方式工作。但是,有没有办法找出该请求仍然是临时的还是实际上始终允许的?

As per the WWDC video, https://developer.apple.com/videos/play/wwdc2019/705/, when you ask for "AlwaysAuthorization" permission you will see only "When In Use, Once and Don't allow". Even if you tap on "When In Use", the delegate call back will come back as kCLAuthorizationStatusAuthorizedAlways. This is working as expected. But is there a way to find out that the request is still provisional or actually-always-allow?

没有与此权限相关的枚举。唯一允许的枚举是:

There is no enum associated to this permission. The only allowed enums are:

kCLAuthorizationStatusNotDetermined, kCLAuthorizationStatusDenied, kCLAuthorizationStatusAuthorizedAlways, kCLAuthorizationStatusAuthorizedWhenInUse

因为我想在用户授予 正在使用权限后立即显示警报告诉他们该应用程序仅在您通过系统偏好设置提供 始终允许时才能运行,并且我可以通过点击将其导航到我的应用程序的系统设置页面,就像Zenly的工作方式: https:/ /www.macrumors.com/2019/08/16/app-developers-tracking-restrictions-ios-13/

Because I want to show an alert as soon as user grants the "While In Use" permission, to tell them that the app will only work if you provide "Always Allow" via system preferences and I can navigate them to the system settings page of my app via a tap, just like how Zenly is doing it: https://www.macrumors.com/2019/08/16/app-developers-tracking-restrictions-ios-13/

推荐答案

您可以检查应用程序进入后台后,是否在后台获取位置更新超过10秒钟。如果是,那么您将拥有永久的允许始终。如果不是,则您具有临时允许始终(或您可以明确检查的任何其他授权)。

You can check if you're getting location updates in the background for more than 10 seconds after the application gets in the background. If yes, then you have the permanent Allow Always. If not, then you have the provisional Allow Always (or any other authorization that you can check explicitly).

这篇关于iOS 13检查CLLocationManager的临时授权状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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