国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS11中的定位授權的解決方法

2020-07-26 02:29:52
字體:
來源:轉載
供稿:網友

本文介紹了iOS11中的定位授權的解決方法,分享給大家,具體如下:

前臺定位權限

1,增加NSLocationWhenInUseUsageDescription。
2,創建CLLocationManager對象,在使用定位服務前調用requestWhenInUseAuthorization()。
3,通過func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)處理權限變化。該函數并不會在每次改改變權限后都會被調用。

參考:
https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services/requesting_when_in_use_authorization

前后臺定位權限

如果希望在app在前臺后臺都可以使用定位服務,需要完成以下幾點:

1,在plist中增加NSLocationWhenInUseUsageDescription和NSLocationAlwaysAndWhenInUsageDescription,如果需要支持iOS10的話,增加NSLocationAlwaysUsageDescription。

2,創建CLLocationManager對象,用requestWhenInUseAuthorization()獲得基本定位支持,用requestAlwaysAuthorization()獲得前后臺定位支持。

3,在第一次調用requestAlwaysAuthorization()時,會提示NSLocationAlwaysAndWhenInUsageDescription中指定的文字,讓用戶選擇是升級到全權限還是,前臺權限。

4,通過func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)處理權限變化。該函數并不會在每次改改變權限后都會被調用。

參考:

https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services/request_always_authorization

注意:

requestWhenInUseAuthorization只有在用戶未選擇時會彈出對話框。

* When +authorizationStatus != kCLAuthorizationStatusNotDetermined, (ie

* generally after the first call) this method will do nothing.

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 廉江市| 甘南县| 安泽县| 五指山市| 绥阳县| 古丈县| 务川| 全椒县| 上林县| 易门县| 和田市| 弥渡县| 华池县| 滁州市| 合水县| 漾濞| 江川县| 新野县| 鹰潭市| 唐海县| 平武县| 泰顺县| 久治县| 泗洪县| 定结县| 右玉县| 阳春市| 云林县| 普陀区| 隆回县| 正安县| 得荣县| 晴隆县| 阳新县| 祁连县| 玉溪市| 东至县| 永登县| 金湖县| 仪陇县| 孙吴县|