ios定位权限plist_iOS-info.plist 中添加定位权限
一般在項(xiàng)目中添加權(quán)限只需要看這一篇文章:https://www.jianshu.com/p/2a309504cec8 就夠了,但是位置權(quán)限說明有點(diǎn)麻煩,現(xiàn)總結(jié)如下,方便后期使用。
定位權(quán)限一般有四個(gè):
NSLocationWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationUsageDescription
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription :用在 iOS app上,只能用于應(yīng)用在前臺(tái)時(shí)需要獲取用戶位置的權(quán)限說明
官方解釋如下:
Use this key if your iOS app accesses location information only when running in the foreground
NSLocationAlwaysAndWhenInUseUsageDescription:用在 iOS app上, 用于應(yīng)用在后臺(tái)時(shí)需要獲取用戶位置的權(quán)限說明
官方解釋如下:
Use this key if your iOS app accesses location information while running in the background
我一般會(huì)在info.plist 文件中同時(shí)添加 NSLocationWhenInUseUsageDescription 和 NSLocationAlwaysAndWhenInUseUsageDescription,只添加一種好像是不談出權(quán)限彈框
位置彈框如下:
位置權(quán)限彈框.png
NSLocationUsageDescription:用在 macOS app上,用于獲取用戶位置信息的權(quán)限說明
官方解釋如下:
Use this key in a macOS app that accesses the user’s location information
NSLocationAlwaysUsageDescription:用在 iOS app 上,用于 iOS11 之前,應(yīng)用在后臺(tái)時(shí)需要獲取位置權(quán)限說明,需要跟NSLocationAlwaysAndWhenInUseUsageDescription 一起添加,iOS11 之后,只添加NSLocationAlwaysAndWhenInUseUsageDescription就可以了
官方解釋如下:
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`](apple-reference-documentation://hspmGRevlx) 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 assocated with `NSLocationAlwaysAndWhenInUseUsageDescription`.
先記錄這些,感謝閱讀,如有錯(cuò)誤,不吝賜教!
總結(jié)
以上是生活随笔為你收集整理的ios定位权限plist_iOS-info.plist 中添加定位权限的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: centos 7 ssh 安装mysql
- 下一篇: Codeforces Round #70