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