checkScreenCapturePermission static method

Future<bool> checkScreenCapturePermission()

Check if screen capture permission is granted (macOS only).

On macOS 10.15+, this uses CGPreflightScreenCaptureAccess. On other platforms, returns true.

Implementation

static Future<bool> checkScreenCapturePermission() async {
  if (kIsWeb) {
    return true;
  }

  // Only macOS has this specific permission check
  if (!Platform.isMacOS) {
    return true;
  }

  try {
    final result =
        await _channel.invokeMethod<bool>('checkScreenCapturePermission');
    return result ?? false;
  } on PlatformException catch (e) {
    debugPrint('Failed to check screen capture permission: ${e.message}');
    return false;
  } on MissingPluginException {
    debugPrint('QuickRTC platform plugin not available');
    return true;
  }
}