-->

Ask for only Request Always Authorization, and not

2019-07-26 15:12发布

问题:

In iOS 11 onwards we follow these instructions from Apple:

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?

回答1:

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.