我有一个应用程序(由ElectronJS制成),该应用程序具有访问权限(通过iohook
包来监听鼠标/键盘事件)。我想将其放在Mac App Store上,但它似乎(1)Mac App Store需要沙箱,并且(2)沙箱不允许访问权限。因此,Mac App Store中的应用程序无法获得辅助功能权限。这是对的还是我缺少什么?谢谢。
您需要使用AXIsProcessTrustedWithOptions来请求对可访问性权限的访问。
这里是Apple的完整文档:https://developer.apple.com/documentation/applicationservices/1459186-axisprocesstrustedwithoptions
示例:
let promptFlag = kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString
let myDict: CFDictionary = NSDictionary(dictionary: [promptFlag: true])
AXIsProcessTrustedWithOptions(myDict)
if (AXIsProcessTrustedWithOptions(myDict))
{
//we have permission granted here
}