日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

ios定位权限plist_iOS-info.plist 中添加定位权限

發布時間:2024/7/5 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 中添加定位权限的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。