適配iOS10 的相關權限設置

參考一:app

最近升級了Xcode8.0,真是不少坑啊,填完一個來另一個,今天又遇到了一個,用Xcode8.0上傳項目時被駁回說是info.plist裏面沒有設置NSPhotoLibraryUsageDescription、NSCameraUsageDescription、NSContactsUsageDescription、NSMicrophoneUsageDescription等字段,以前這些都是預設的不用加,如今強制了,真是鬱悶,下面貼上解決方案this

被駁回的緣由:.net

This app attempts to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.code

This app attempts to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.cdn

大概意思就是得在plist裏面必須加上NSPhotoLibraryUsageDescription和NSCameraUsageDescription的鍵值對才行,以前都是默認的,如今必須加,要不不讓經過,真是坑啊~~具體配置以下圖:blog

這裏寫圖片描述

1-2.jpg

大概統計了一下須要加的一些字段列在下面:圖片

  • NSContactsUsageDescription -> 通信錄ip

  • NSMicrophoneUsageDescription -> 麥克風字符串

  • NSPhotoLibraryUsageDescription -> 相冊get

  • NSCameraUsageDescription -> 相機

  • NSLocationAlwaysUsageDescription -> 地理位置

  • NSLocationWhenInUseUsageDescription -> 地理位置

  • Privacy - Bluetooth Peripheral Usage Description -> 藍牙權限

  • Privacy - Speech Recognition Usage Description -> 語音轉文字權限

  • Privacy - Calendars Usage Description -> 日曆權限

  • Privacy - Contacts Usage Description -> 通信錄權限

大概就是以上的一些字段,寫一篇博客總結一下,方便之後用到的時候能找到,若是你們有補充的能夠告訴我一下,謝謝你們的閱讀

參考二

解決辦法(fix method):
info.plist —Source Code中添加
UsageDescription相關的key, 描述字符串本身隨意填寫就能夠,可是必定要填寫,否則會引起包無效的問題,致使上傳打包後構建版本一直不顯示

<!-- 相冊 --> 
<key>NSPhotoLibraryUsageDescription</key> 
<string>App須要您的贊成,才能訪問相冊</string> 
<!-- 相機 --> 
<key>NSCameraUsageDescription</key> 
<string>App須要您的贊成,才能訪問相機</string> 
<!-- 麥克風 --> 
<key>NSMicrophoneUsageDescription</key> 
<string>App須要您的贊成,才能訪問麥克風</string> 
<!-- 位置 --> 
<key>NSLocationUsageDescription</key> 
<string>App須要您的贊成,才能訪問位置</string> 
<!-- 在使用期間訪問位置 --> 
<key>NSLocationWhenInUseUsageDescription</key> 
<string>App須要您的贊成,才能在使用期間訪問位置</string> 
<!-- 始終訪問位置 --> 
<key>NSLocationAlwaysUsageDescription</key> 
<string>App須要您的贊成,才能始終訪問位置</string> 
<!-- 日曆 --> 
<key>NSCalendarsUsageDescription</key> 
<string>App須要您的贊成,才能訪問日曆</string> 
<!-- 提醒事項 --> 
<key>NSRemindersUsageDescription</key> 
<string>App須要您的贊成,才能訪問提醒事項</string> 
<!-- 運動與健身 --> 
<key>NSMotionUsageDescription</key> <string>App須要您的贊成,才能訪問運動與健身</string> 
<!-- 健康更新 --> 
<key>NSHealthUpdateUsageDescription</key> 
<string>App須要您的贊成,才能訪問健康更新 </string> 
<!-- 健康分享 --> 
<key>NSHealthShareUsageDescription</key> 
<string>App須要您的贊成,才能訪問健康分享</string> 
<!-- 藍牙 --> 
<key>NSBluetoothPeripheralUsageDescription</key> 
<string>App須要您的贊成,才能訪問藍牙</string> 
<!-- 媒體資料庫 --> 
<key>NSAppleMusicUsageDescription</key> 
<string>App須要您的贊成,才能訪問媒體資料庫</string>

iOS 10 開始對隱私權限更加嚴格, 如需使用隱私權限須要在工程的info.plist文件中聲明,若是不聲明程序在調用隱私權限(如相機)時應用程序會崩潰
離線打包用戶須要手動添加權限到打包工程的info.plist文件中

key可從如下表中獲取,value爲彈框提示文字用戶可隨意添加,類型String

權限名稱 Key值
通信錄 NSContactsUsageDescription
麥克風 NSMicrophoneUsageDescription
相冊 NSPhotoLibraryUsageDescription
相機 NSCameraUsageDescription
持續獲取地理位置 NSLocationAlwaysUsageDescription
使用時獲取地理位置 NSLocationWhenInUseUsageDescription
藍牙 NSBluetoothPeripheralUsageDescription
語音轉文字 NSSpeechRecognitionUsageDescription
日曆 NSCalendarsUsageDescription

參考資料

http://blog.csdn.net/wang631106979/article/details/52578001

http://blog.csdn.net/qq_30513483/article/details/52587483

http://blog.csdn.net/dcw050505/article/details/53038798

http://ask.dcloud.net.cn/article/931

相關文章
相關標籤/搜索