本文介绍了iOS13临时位置权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于苹果推迟了始终允许权限,并且只有操作系统可以并且会根据自己的方便性来请求该权限,所以很难理解所有情况。

Since apple has deferred the "Always Allow" permission and only OS can and will ask for that permission based on its own convenience, it is hard to understand what all the scenarios are.

如果您看到WWDC视频:

If you see the WWDC video: https://developer.apple.com/videos/play/wwdc2019/705/

该人清楚地在04:14说:您要请求始终授权,苹果为您提供了max选项为在使用中,但同时委托回调显示,该应用程序具有始终允许权限。这可以按预期工作,并且只有在我保持打开状态的情况下,我的应用才能获取位置更新。他说,在04:35,开始进行Geofence活动是作为背景跟踪/始终允许的要求。这就是让我感到困惑的地方,如果我将我的应用程序置于后台,位置更新将停止。为什么即使我的代表回电获得了始终允许权限,我仍要求为已经在运动中的用户设置地理围栏?

The guy clearly says at 04:14, "you ask for requestAlwaysAuthorization, apple provides you with the max option of "While In Use", but at the same time the delegate callback says, the app has "Always Allow permission"". This works as expected, and my app gets the location updates, only If I keep it opened. At 04:35 he says, start Geofence activity as a background-tracking/always-allow requirement. This is where it confuses me, If I put my app in background, location updates are stopped. Why am I asked to setup a geofence for a user who is already in motion even when my delegate call back received "Always Allow" permission?

在05:22,锁定临时设备并在打开设备后将其解锁的​​时候,巩固临时总允许权限的弹出窗口只会出现(在OS方便时)如上段所述,它在后台运行。但是之间的所有数据都会丢失。我的应用程序跟踪用户的行程,这将完全杀死记录用户在车辆中运动的有效用例。

At 05:22, the pop up which solidifies the provisional always allow permission only comes up (at OS convenience), when you lock the device and unlock it, after putting it in the background as discussed in above paragraph. But all the data in between is lost. My app tracks user's trips and this will completely kill the valid use case of recording user's movement in a vehicle.

即使我跟随视频并在应用程序进入后台然后开始移动时创建地理围栏,也不会发生任何事情,除非我锁定和解锁设备。

Even if I follow the video and create a geofence when app goes to the background and then start to move, nothing happens until I lock and unlock the device. This seems to be pretty useless.

推荐答案

您不是。您误解了视频。他以使用Always权力为例。这只是一个例子。

You’re not. You’ve misunderstood the video. He gives that as an example of using Always powers. It’s just an example.

不是。听他在视频中说的话。如果用户现在接受始终,则将传递保留的委托消息。

No it isn’t. Listen to what he says in the video. If the user now accepts Always, the withheld delegate message is delivered.

不,不会。该用例与您先前所说的无关。如果您的应用正在跟踪前景中的位置,并使用背景位置模式进入后台并保持跟踪,则该应用正在使用中。因此,您所需要的就是使用时。因此,所有Always东西与您无关。

No it won’t. That use case has nothing to do with anything you said previously. If your app is tracking location in the foreground and goes into the background with background location mode and keeps tracking, it is in use. So all you need for that is When In Use. So all that Always stuff is irrelevant to you.

这就是视频的重点。除非您需要,否则请不要要求始终。如果您确实需要它,请使用它,否则您将无法获得它。但是看来,您不需要它。

That is the whole point of the video. Don’t ask for Always unless you need it. If you do ask for it, use it, or you won’t get it. But you, it appears, don’t need it.

这篇关于iOS13临时位置权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 07:18
查看更多