How to resolve macOS permission issues?
How to check if the computer has enabled screen capture permission and accessibility for the application?
Please open the "System Preferences" on your macOS computer, find the "Security & Privacy" option, switch to the "Privacy" tab, and confirm whether the following permissions are enabled:
Why is it still unable to capture images or report errors after enabling permissions?
The status seen in the "Settings" on the macOS computer is not the real status of the application. It is recommended to use code to determine whether permissions are enabled (please refer to "How to determine system permissions?" below).
If permissions have been enabled, please close them first and then open them again to retry.
How to jump to the system settings permission dialog?
Please refer to this URL to set "System Related URLs": MacOS System Preference Links.
How to determine system permissions?
-
Accessibility permission
You can confirm the permission by calling the following SDK internal interface.
SCREENCAPTURE_API bool zego_windowthumbnail_window_checkStatus(ZegoWindowHandle handle); -
Screen recording permission
After macOS 10.15 version, this permission needs to be enabled. The SDK does not have a wrapper for this permission function, and users need to implement it themselves. Please refer to the following code:
bool ZegoSDKEngineMacUtils::checkScreenCapturePermission() { if (QSysInfo::macVersion() < 14) { return true; } if (@available(macOS 10.15, *)) { CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); NSUInteger numberOfWindows = CFArrayGetCount(windowList); NSUInteger numberOfWindowsWithInfoGet = 0; for (int idx = 0; idx < numberOfWindows; idx++) { NSDictionary *windowInfo = (NSDictionary *)CFArrayGetValueAtIndex(windowList, idx); NSString *windowName = windowInfo[(id)kCGWindowName]; NSNumber* sharingType = windowInfo[(id)kCGWindowSharingState]; if (windowName || kCGWindowSharingNone != sharingType.intValue) { numberOfWindowsWithInfoGet++; } else { NSNumber* pid = windowInfo[(id)kCGWindowOwnerPID]; NSString* appName = windowInfo[(id)kCGWindowOwnerName]; // NSLog(@"windowInfo get Fail pid:%lu appName:%@", pid.integerValue, appName); } } CFRelease(windowList); if (numberOfWindows == numberOfWindowsWithInfoGet) { return true; } else { return false; } } return true; }
