1
我正在用swift編寫macOS應用程序,希望能夠在計算機上以編程方式啓用文本到用戶的語音,一旦他們下載我的應用程序。我不確定使用什麼命令來重新配置用戶的設置並要求許可更改其可訪問性設置。有誰知道如何做到這一點或在哪裏找到解釋如何做到這一點的文檔?使用Swift修改macOS上的可訪問性設置
我正在用swift編寫macOS應用程序,希望能夠在計算機上以編程方式啓用文本到用戶的語音,一旦他們下載我的應用程序。我不確定使用什麼命令來重新配置用戶的設置並要求許可更改其可訪問性設置。有誰知道如何做到這一點或在哪裏找到解釋如何做到這一點的文檔?使用Swift修改macOS上的可訪問性設置
Apple要求您明確說明可訪問性設置。從塞拉利昂,不可能再把它設置在數據庫上。因此,用戶必須點擊並啓用您的應用才能訪問。
public func checkAccess() -> Bool{
//get the value for accesibility
let checkOptPrompt = kAXTrustedCheckOptionPrompt.takeUnretainedValue() as NSString
//set the options: false means it wont ask
//true means it will popup and ask
let options = [checkOptPrompt: true]
//translate into boolean value
let accessEnabled = AXIsProcessTrustedWithOptions(options as CFDictionary?)
return accessEnabled
}