launch static method

Future<void> launch()

Launches the ongoing call service with a persistent notification.

On Android, this starts a foreground service that:

  • Shows a persistent notification with "Call in progress"
  • Provides Mute/Unmute action button
  • Provides Hang up action button
  • Tapping the notification returns to the call screen

On iOS, this is a no-op as iOS handles call notifications differently through CallKit.

Implementation

static Future<void> launch() async {
  if (kIsWeb || defaultTargetPlatform != TargetPlatform.android) {
    // iOS uses CallKit for call notifications, web doesn't need this
    return;
  }

  try {
    await CometChatCallsPluginPlatform.instance
        .nativeLaunchOngoingCallService();
  } catch (e) {
    // Log error but don't throw - notification is not critical
    print('$_tag: Error launching ongoing call service: $e');
  }
}