Mac App Store中的应用程序能否获得可访问性权限?

问题描述 投票:1回答:1

我有一个应用程序(由ElectronJS制成),该应用程序具有访问权限(通过iohook包来监听鼠标/键盘事件)。我想将其放在Mac App Store上,但它似乎(1)Mac App Store需要沙箱,并且(2)沙箱不允许访问权限。因此,Mac App Store中的应用程序无法获得辅助功能权限。这是对的还是我缺少什么?谢谢。

macos electron mac-app-store code-signing-entitlements accessibility-api
1个回答
0
投票

您需要使用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
}
© www.soinside.com 2019 - 2024. All rights reserved.