Overview
When a user leaves your call screen, the operating system may terminate it to free resources. The SDK providesCometChatOngoingCallService — 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.
Implementation
Step 1: Add Manifest Permissions (Android)
Add the required permissions to yourandroid/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.Related Documentation
- Picture-in-Picture - Keep call visible while using other apps
- VoIP Calling - Receive calls when app is killed
- Session Status Listener - Listen for session events