今天寫二維碼功能露氮,訪問相冊時(shí)總是崩潰
log如下:
This app has crashed because it attempted 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.
不難翻譯峡碉,大體意思就是這個(gè)App缺少一個(gè)獲取私有(敏感)數(shù)據(jù)的權(quán)限描述瞎惫,需要我們在info.plist文件中必須含
有一個(gè)名字叫做NSPhotoLibraryUsageDescription的值來解釋為什么應(yīng)用需要使用這個(gè)數(shù)據(jù),沒錯(cuò)胎源,獲取相冊
資源的鍵值就是NSPhotoLibraryUsageDescription
感覺它”友好”的提示之后棉钧,就去plist文件中添加了下面的鍵值:
page.1
這個(gè)時(shí)候再點(diǎn)擊獲取圖片資源,就彈出了一個(gè)獲取權(quán)限的問候涕蚤,不會(huì)發(fā)生崩潰了:
page.2
通過類似事情宪卿,說明iOS10對用戶的隱私又做了進(jìn)一步加強(qiáng),就好像當(dāng)初iOS8對定位隱私進(jìn)行加強(qiáng)一樣万栅,作為開發(fā)者的我們貌似也是應(yīng)該時(shí)刻保持這種對新知識警覺性的佑钾。
除了相冊的權(quán)限,iOS10之后如下的權(quán)限請求也是需要我們填寫請求描述的申钩,在這里也給大家提醒一下:
<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能訪問相冊</string>
<key>NSCameraUsageDescription</key>
<string>App需要您的同意,才能訪問相機(jī)</string>
<key>NSMicrophoneUsageDescription</key>
<string>App需要您的同意,才能訪問麥克風(fēng)</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需要您的同意,才能訪問提醒事項(xiàng)</string>
<key>NSMotionUsageDescription</key>
<string>App需要您的同意,才能訪問運(yùn)動(dòng)與健身</string>
<key>NSHealthUpdateUsageDescription</key>
<string>App需要您的同意,才能訪問健康更新 </string>
<key>NSHealthShareUsageDescription</key>
<string>App需要您的同意,才能訪問健康分享</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App需要您的同意,才能訪問藍(lán)牙</string>
<key>NSAppleMusicUsageDescription</key>
<string>App需要您的同意,才能訪問媒體資料庫</string>
ximen.png