Skip to main content
Keep calls alive when users navigate away from your app. Background handling ensures the call continues running when users press the home button, switch to another app, or lock their device.

Overview

When a user leaves your call screen, the operating system may terminate it to free resources. The SDK provides CometChatOngoingCallService — a utility that:
  • Keeps the call session active in the background
  • Shows an ongoing notification in the status bar (Android)
  • Allows users to return to the call with a single tap
  • Provides a hangup action directly from the notification

When to Use

Background Handling is different from VoIP Calling. VoIP handles receiving calls when the app is not running. Background Handling keeps an active call alive when the user leaves the app.
CometChatOngoingCallService starts an Android foreground service with a persistent notification showing mute/unmute and hang up actions. On iOS, this is a no-op since iOS uses CallKit for ongoing call notifications.

Implementation

Step 1: Add Manifest Permissions (Android)

Add the required permissions to your android/app/src/main/AndroidManifest.xml:

Step 2: Start Service on Session Join

Start the ongoing call service when the user successfully joins a call session:
Flutter listeners are not lifecycle-aware. You must manually remove listeners in dispose() and call CometChatOngoingCallService.abort() to clean up.

Complete Example


API Reference

CometChatOngoingCallService

On iOS, ongoing call state is managed by CallKit automatically. CometChatOngoingCallService.launch() and abort() are safe to call on iOS — they simply do nothing.