I am developing an utility for OSX which need to use Universal Access (accessibility and event tap).
I am using AXIsProcessTrustedWithOptions to check if the application is allowed. I am checking this state every second (pooling) in order to detect when user is allowing it.
Unfortunately, AXIsProcessTrustedWithOptions is always returning false, even when the application has been allowed.
I know it is possible because others applications like popclip are doing it but I cannot figure out what I am doing wrong.
Added: code
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:(id)kCFBooleanTrue, kAXTrustedCheckOptionPrompt, nil];
if (!AXIsProcessTrustedWithOptions((CFDictionaryRef)options) ) {
while (!AXIsProcessTrustedWithOptions(NULL)) {
NSLog(@"Still not allowed");
[NSThread sleepForTimeInterval:1.0f];
}
NSLog(@"user just allowed the application");
}
else
{
NSLog(@"App is already allowed");
}