Can an app in the Mac App Store ever get Accessibility permission?

Viewed 673

I've got an app (made with ElectronJS) that relies on having Accessibility permission to listen for mouse/keyboard events (via the iohook package). I'd like to put it on the Mac App Store, but it appears that:

  1. Mac App Store requires Sandboxing and
  2. Sandboxing does not allow Accessibility permission.

Therefore an app in the Mac App Store cannot get Accessibility permission. Is this right or am I missing something?

1 Answers

You need to use AXIsProcessTrustedWithOptions to request access to Accessibility Permissions.

Here is the full doc from Apple: https://developer.apple.com/documentation/applicationservices/1459186-axisprocesstrustedwithoptions

Example:

let promptFlag = kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString
let myDict: CFDictionary = NSDictionary(dictionary: [promptFlag: true])
AXIsProcessTrustedWithOptions(myDict)

if (AXIsProcessTrustedWithOptions(myDict))
{
    //we have permission granted here
}
Related