requestScreenCapturePermission static method

Future<bool> requestScreenCapturePermission()

Request screen capture permission (macOS only).

On macOS 10.15+, this uses CGRequestScreenCaptureAccess which shows the system permission dialog. Note that this dialog only appears once per app install. If the user denies permission, they must manually enable it in System Preferences > Security & Privacy > Screen Recording.

On other platforms, returns true.

Implementation

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

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

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