日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時(shí)間:2024/7/5 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ios定位权限plist_iOS-info.plist 中添加定位权限 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

一般在項(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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。