我还尝试遵循本书的WWDC要求,始终要求.总是接收临时请求,然后相信OS会在某个阶段显示对话框-没有运气.更麻烦的是,即使我将我的应用程序的权限设置手动更改为真正的.always权限,该应用程序仍无法在后台对位置进行定位.如果一直要求.al并获得临时" always许可,我希望在某个阶段显示位置对话框的OS提出真正" .always许可.尽管在10倍的背景下进入了地理围栏,但这已经有两周没有发生了.我还希望许可升级"流程能够正常工作,尽管在WWDC视频和coreLocation文档中都有解释,但事实并非如此.如果Apple继续使用iOS 13,我希望许多在后台合法位置的应用程序将完全无法正常工作.有人在这方面取得任何进展吗?我已向Apple提出了反馈",但希望在9月的iOS 13 GM之前不会及时收到他们的答复.解决方案在iOS 13中向用户请求其始终"位置许可时:locationManager.requestAlwaysAuthorization() 1)用户将收到此警报: 2)如果您请求始终许可,而用户选择Allow While in Use,则您的应用将认为它获得了.authorizedAlways许可,但这就是provisional .authorizedAlways许可. 3)接下来,当您的应用通常会在后台接收位置事件时,iOS不会直接在后台通过事件启动您的应用,而是等待它认为用户没有做任何事情,然后会显示此对话框: 根据视频,这可能需要一段时间( 6: 39 ): 用户可以向您的应用授予始终授权的提示将在稍后出现. {...}当我们认为用户不忙时,核心位置会等待一段时间,以最大程度地提高他们了解正在发生的事情的能力,并最大程度地降低他们给出自己的出路的可能性一种回应.在此过程中(在应用程序进入后台和显示提示之间),您将不会收到位置更新事件: 如果您的应用最终获得了始终的授权,而没有收到使用中的授权,则将交付它们.但是,如果用户还没有选择,它们也不会被交付. 因此,在此期间,如果在此基础上生成了更多事件,并且您正在监视请求,则这些事件将替换较早出现的事件,而较早的那些事件将被丢弃.最后,Core Location将删除事件部分,以解决任何已过时的问题. 4)然后,当用户选择Change to Always Allow时,.authorizedAlways权限将变为最终权限(除非用户将来更改其设置).然后,您将开始接收位置事件.除非(5)用户选择Keep Only While Using,否则最终许可将变为.authorizedWhenInUse.以下是演示文稿的概述(数字是我的): 另一个指向完整视频的链接: https://developer.apple.com/视频/播放/wwdc2019/705 这能回答您的问题吗? 如果我将我的应用程序的权限设置手动更改为真正的始终权限,则该应用程序将继续无法在后台定位位置.事实并非如此.您是否在系统偏好设置中进行了更改? 尝试使用GM种子,也许他们修复了有关此流程的一些错误. Under iOS13, when you request the .always permission for coreLocation (to enable background location e.g. for geofences or iBeacons), the app is only granted a "provisional always" permission, which does not allow it to use coreLocation in the background. At a later stage, in principle the OS should popup a permission request to switch to the .always permission. I have yet to experience it, and it seems (looking at Apple developer forums) that nobody have found a way to consistently trigger this dialog popup.I have asked for .always (which can only provide a useless "provisional always" permission), and then tried to "upgrade" to a real .always permission, but nothing happens (no popup, no permission change)I have also tried to follow the WWDC recommandation by the book, asking for .always, receiving provisional always, and then trusting that the OS would show the dialog at some stage - with no luck.Even more troublesome, even if I change manually the permission setting to a real .always permission for my app, the app continues to be unable to range locations in the background.If asking for .always and receiving a "provisional" always permission, I would expect the OS the show the location dialog at some stage to propose a "real" .always permission. This hasn't happened in 2 weeks, despite entering geofences in the background 10's of times.I would also expect the permission "upgrade" flow to work, which is not the case despite what's explained in the WWDC video and docs for coreLocation.If Apple goes ahead with iOS 13 as is, I expect that numerous apps which legitimately range location in the background will stop working as expected entirely.Has anybody made any progress on that front ? I have filed a "feedback" to Apple, but don't expect to receive a timely response from them before the September iOS 13 GM. 解决方案 When you request a user for their "Always" location permission in iOS 13:locationManager.requestAlwaysAuthorization()1) The user will get this alert: 2) If you asked for always permission and your user chooses Allow While in Use your app will think it got the .authorizedAlways permission but this is the provisional .authorizedAlways permission. 3) Next, when your app would normally receive location events in the background iOS does not directly launches your app in the background with the events but waits until it thinks the user is not doing anything and it then will present this dialog: According to the video, this can take a while (6:39): The prompt that the user can grant your app always authorization from will occur later. {...} Core Location waits for a time when we think that the user is not busy in order to maximize their ability to understand what's going on and minimize the chance that they'll give a get-out-of-my-way kind of response.During this this (in between the app going to the background and the prompt being shown) you won't receive location update events: They'll be delivered if you app receives always authorization ultimately and not if it receives a when in use authorization. But they also won't be delivered if the user just hasn't chosen yet. So, during this time, if more events are generated on that basis, if you're monitoring requests, then those events will displace the ones that came earlier, and the earlier ones will be dropped. And then finally Core Location will drop the event part for anything that's become just too old. 4) Then when the user chooses Change to Always Allow, the .authorizedAlways permission will become final (unless the user changes it from the settings somewhere in the future). And you will start to receive location events.Unless (5) the user chooses Keep Only While Using and the final permission will become .authorizedWhenInUse.Here's the overview from the presentation (numbers mine):And another link to the full video: https://developer.apple.com/videos/play/wwdc2019/705Does that answer your questions? If I change manually the permission setting to a real .always permission for my app, the app continues to be unable to range locations in the background.That should not be the case. Did you change it in the system preferences? Try the GM seed, maybe they fixed some bugs regarding this flow. 这篇关于有没有办法在iOS13中主动触发.always coreLocation权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-14 20:02