仅请求“始终请求授权",而不是“使用时授权" [英] Ask for only Request Always Authorization, and not When-In-Use Authorization

查看:78
本文介绍了仅请求“始终请求授权",而不是“使用时授权"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从iOS 11开始,我们按照Apple的这些说明进行操作:

In iOS 11 onwards we follow these instructions from Apple:

您需要包括NSLocationWhenInUseUsageDescription 和您应用程式中的NSLocationAlwaysAndWhenInUsageDescription键 Info.plist文件. (如果您的应用支持iOS 10及更低版本, 还需要NSLocationAlwaysUsageDescription键.)如果这些键 不存在,授权请求将立即失败.

You are required to include the NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUsageDescription keys in your app's Info.plist file. (If your app supports iOS 10 and earlier, the NSLocationAlwaysUsageDescription key is also required.) If those keys are not present, authorization requests fail immediately.

当提示用户启用位置跟踪时,这将同时显示始终"和在使用中"选项.

This shows both "Always" and "When in Use" options when the user is prompted to enable location tracking.

但是,我们只想显示始终"选项.这可能吗?

However we'd like to show just the "Always" option. Is this possible?

推荐答案

在iOS 11上,这是不可能的.如果您要求始终",则必须处理使用中"的情况. 此WWDC视频在时间10:55开始明确说明.

On iOS 11, that is not possible. You are required to handle the case of "when in use" if you are asking for "always". It is explained clearly in this WWDC video starting at time 10:55.

这篇关于仅请求“始终请求授权",而不是“使用时授权"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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