To be able to use certain features, users need to enable apps in accessibility panel. There are two ways to bring up the page shown as below
Solution 1
NSDictionary* options = @{static_cast<id> (kAXTrustedCheckOptionPrompt): @YES};
return AXIsProcessTrustedWithOptions(static_cast<CFDictionaryRef> (options));
Solution 2
NSString* urlString = @"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility";
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:urlString]];
Compared to solution 1, solution 2 doesn't require the explaining dialog which introduces one extra click. And this is the main reason I prefer using solution 2.
But what I find is sometimes the app I enabled is not recognized by the system using solution 2. Because sometimes even if the app is enabled in accessibility panel, when I start the bundle which would spawn another child process, the standard error outputs something like "assitive device does not trust this process".
Does solution 1 do some hidden tricks while solution 2 doesn't?