简体   繁体   English

iOS 13检查CLLocationManager的临时授权状态

[英]iOS 13 check for provisional authorization status of CLLocationManager

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" . 根据WWDC视频https://developer.apple.com/videos/play/wwdc2019/705/ ,当您请求“ AlwaysAuthorization ”权限时,您只会看到“ 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 . 即使您点击“ When In Use ”,委托回叫也将以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

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/ 因为我想在用户授予“ While In Use ”权限后立即显示警报,所以要告诉他们该应用程序仅在您通过系统偏好设置提供“ Always Allow ”的情况下才可以运行,并且我可以将其导航到的“系统设置”页面就像Zenly一样,通过点击我的应用程序: https ://www.macrumors.com/2019/08/16/app-developers-tracking-restrictions-ios-13/

You can check if you're getting location updates in the background for more than 10 seconds after the application gets in the background. 您可以检查应用程序进入后台后,是否在后台获取位置更新超过10秒钟。 If yes, then you have the permanent Allow Always . 如果是,那么您将拥有永久的Allow Always If not, then you have the provisional Allow Always (or any other authorization that you can check explicitly). 如果不是,则您具有临时的“ Allow Always (或可以明确检查的任何其他授权)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM