本文github地址:github.com/stelalae/bl…
现在隐私保护是越来越重视,获取地理位置难度+++,APP Store在审核时容易发生因位置权限配置不对导致被拒。目前iOS的 info.plist
里有4个位置权限设置项及对应版本:
以下测试分别在iOS的 12.3.1、13.1.2 环境下进行,下文中分别简称iOS12、iOS13。
官网说明, 适用于iOS 6.0–8.0,所以新项目中不再使用,写不写都无所谓。
只允许使用应用期间APP获取地理位置,官网说明,适用于iOS 11.0+。
在iOS 12中
在iOS 13中
Privacy - Location Always Usage Description
和Privacy - Location Always and When In Use Usage Description
,都是申请允许APP在前后台时都能获取地理位置,下面来看看具体区别。
先看官网的说明:
Use this key if your iOS app accesses location information in the background, and you deploy to a target earlier than iOS 11. In that case, add both this key and NSLocationAlwaysAndWhenInUseUsageDescription to your app’s Info.plist file with the same message. Apps running on older versions of the OS use the message associated with NSLocationAlwaysUsageDescription, while apps running on later versions use the one associated with NSLocationAlwaysAndWhenInUseUsageDescription. If your app only needs location information when in the foreground, use NSLocationWhenInUseUsageDescription instead. For more information, see Choosing the Location Services Authorization to Request. If you need location information in a macOS app, use NSLocationUsageDescription instead.
NSLocationAlwaysUsageDescription
的。Use this key if your iOS app accesses location information while running in the background. If your app only needs location information when in the foreground, use NSLocationWhenInUseUsageDescription instead. For more information, see Choosing the Location Services Authorization to Request. If you need location information in a macOS app, use NSLocationUsageDescription instead. If your iOS app deploys to versions earlier than iOS 11, see NSLocationAlwaysUsageDescription.
在iOS 13中
官方建议:Choosing the Location Services Authorization to Request
2020年05月上架一个新包,之前按照别人文档来囫囵吞枣的把位置权限全部加上,于是收到被拒的大礼包:
参考资料: