My sandboxed macOS app requires the user to grant permission under Privacy & Security / Accessibility in order to support extra functionality. If no permission is granted the app can still be used albeit with very basic functionality.
In order to allow the user NOT to have to immediately decide whether to grant this permission when first launching the app, a dialog allows them to say “I’ll do it later”.
As such, the app uses a timer with a one second interval to ask the system if permission has been granted and if so, implements the extra functionality. By the way, I would rather have used a notification instead of a timer, but there does not seem to be one.
// Schedule a timer to periodically check accessibility status
accessibilityTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(checkAccessibilityStatus), userInfo: nil, repeats: true)
func isAccessibilityEnabled() -> Bool {
let accessibilityEnabled = AXIsProcessTrusted()
return accessibilityEnabled
}
@objc func checkAccessibilityStatus() {
if isAccessibilityEnabled() {
print("Accessibility is enabled.")
accessibilityTimer?.invalidate()
if gEventTap == nil {
tapper()//as003
gTypeIt4MeMenu?.item(at: kPauseResumeItem)?.title = "Pause"
gStatusItem?.button!.image = NSImage(named: "menubar_icon_16x16")
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "showGreenTick"), object: nil)
}
} else {
print("Accessibility is disabled.")
}
}
My problem is that when I build the app with my development certificate, it runs as expected.
However, when I upload it to TextFlight and download from there, it no longer “notices” when I grant it permission.