“This app has attempted to access privacy-sensitive data without a usage description” error handling

(error handling, info plist, location)

取得手機座標時,需要在plist文件中定義

Privacy — Location When In Use Usage Description

但若出現下圖之訊息

This app has attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain both “NSLocationAlwaysAndWhenInUseUsageDescription” and “NSLocationWhenInUseUsageDescription” keys with string values explaining to the user how the app uses this data

可參考本文設定權限

使用Source Code開啟plist檔案
(右鍵 -> Open As -> Source Code)

增加 “NSLocationAlwaysAndWhenInUseUsageDescription”

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>
取得現在位置以便呈現資訊</string>
<key>
NSLocationWhenInUseUsageDescription</key>
<string>
取得現在位置以便呈現資訊</string>

執行後,會先詢問取得位置之權限

--

--