Im working on a small text snippet / lorem ipsum app as a side project and the idea is, for instance, whenever and wherever user types "lorem10" I'd like to print/paste 10 random lorem ipsum words.
Eg. "lorem10 " -> ("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do")
For that to be possible I need to,
Programmatically press "delete" key to remove the trigger string ("lorem10").
Programmatically press "cmd + v" for pasting the result string.
This is possible, even in sandbox! But it requires accessibility permission. For instance I can simulate "delete" key press like this:
func delete() {
let eventSource = CGEventSource(stateID: .combinedSessionState)
let keyDownEvent = CGEvent(
keyboardEventSource: eventSource,
virtualKey: CGKeyCode(51),
keyDown: true)
let keyUpEvent = CGEvent(
keyboardEventSource: eventSource,
virtualKey: CGKeyCode(51),
keyDown: false)
let loc = CGEventTapLocation.cghidEventTap
//Triggers system default accessibility access pop-up
keyDownEvent?.post(tap: loc)
keyUpEvent?.post(tap: loc)
}
My question is essentially if this is allowed in Mac App Store? Because requesting accessibillity permission like this is not allowed in sandbox:
func getPermission() {
AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt.takeUnretainedValue():true] as CFDictionary).
}
But I can simulate one short "shift" or "cmd" key press for instance, and trigger the pop-up inside a sandboxed app and get around this it seems. Is this a bug?
I really hope I can release my app in the Mac App Store, but doing so I just want to be sure Im not using any bug that might get removed in the near future.
Post
Replies
Boosts
Views
Activity
Is it possible to create a sandboxed app that uses accessibility permission? And if so, how do I ask the user for that permission in a way that is allowed by the App Store?
Im creating a small menubar app and my current (rejected) solution is to create a pop-up, with link to Security & Privacy > Accessibility and the pop-up asks the user to manually add the app to the list and check the checkbox. This works in sandbox.
Reason for rejection:
"Specifically, your app requires to grant accessibility access, but once we opened the accessibility settings, your app was not listed."
I know it's not listed there and it has to be added manually. But its the only solution I've found to this issue. Is there perhaps any way to add the app there programmatically?
Im a bit confused since I've seen other apps in App Store that work the same way, where you have to add the app to the list manually. Eg. Flycut. :man-shrugging:
I know about this alternative solution, and it's not allowed in sandboxed apps. It also adds the app to the accessibility list automagically:
func getPermission() {
AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt.takeUnretainedValue():true] as CFDictionary).
}
Does anyone have a solution for this?
Best regards,
Daniel