Overview
With calling enabled, the UI Kit places calls from the message header and call logs, shows the outgoing call screen, and hosts the in-call screen. Incoming calls ring through the CometChat Push Notifications SDK: it shows the call notification and the full-screen incoming-call screen, plays the ringtone, and opens your answer activity when the user answers, which hands the call to the UI Kit’s call screen, with the app in the foreground, in the background or not running at all.Make sure you’ve completed the Getting Started guide before proceeding.
Step 1: Dependencies
The UI Kit does not bundle the Calls SDK:calls-sdk-android is a compile-only dependency of the kit, so your app declares it. Add the UI Kit module, the Calls SDK, the two Push Notifications SDK artifacts and Firebase Messaging. List the UI Kit before the Push SDK artifacts, so the UI Kit’s incoming-call colours take effect (see Styling the incoming-call screen):
- Kotlin (XML Views)
- Jetpack Compose
build.gradle.kts
google-services plugin and put google-services.json in the app module. minSdk must be 28 or higher, the UI Kit’s minimum.
Step 2: Enable calling in the UI Kit
SetsetEnableCalling(true) in UIKitSettings. CometChatUIKit.init then initialises the Calls SDK with the same app id, region and hosts, and CometChatUIKit.login logs the user into it. Do not call CometChatCalls.init yourself: the Calls SDK keeps the hosts of its first initialisation.
- Kotlin (XML Views)
- Jetpack Compose
Application.onCreate from stored credentials, not only after a screen opens. A push can start the app process to ring a call, and the answer must find a ready SDK.
Step 3: Configure push ringing
Initialise the Push Notifications SDK once, after the UI Kit. It needs the FCM provider id and an answer activity: the screen the Push SDK opens when the user taps Answer.- Kotlin (XML Views)
- Jetpack Compose
AndroidManifest.xml
AndroidManifest.xml
PNConfiguration options (ring timeout, missed-call notifications, your own ring screen) are on the Calls SDK’s Push Ringing page.
Step 4: Permissions
There is nothing to declare.RECORD_AUDIO, CAMERA and POST_NOTIFICATIONS merge into your manifest from the UI Kit, the Calls SDK and the Push SDK’s calls module, along with the permissions ringing needs. You only request them at runtime:
- Notifications: after sign-in, call
CometChatPushNotifications.ensureRingReady(activity) { result -> … }(snippet below) and show the user anyRingReadinessother thanREADY. On Android 13+ it asks forPOST_NOTIFICATIONSitself when it is missing, and reportsNOTIFICATIONS_OFFwhile that prompt is still on screen. Notifications off, a muted call channel, a revoked full-screen intent and Do Not Disturb all silence calls with no error. - Microphone and camera: the Push SDK asks when the user answers, and the UI Kit’s call screen asks once more when it opens; a denied microphone joins muted. Ask at sign-in as well if you do not want the first call to be where the user meets the prompt.
ensureRingReady after those requests have returned; Android drops a permission request made while another dialog is open.
Step 5: Log out through the UI Kit
CometChatUIKit.logout ends a call in progress, cancels an outgoing call still ringing, then logs out of the Chat SDK and the Calls SDK; the Push SDK stops a ring still playing for the old user and unregisters the token. CometChat.logout alone does none of the calling clean-up.
What the UI Kit does from here
Once calling is active, the voice and video call buttons render in the MessageHeader:- Kotlin (XML Views)
- Jetpack Compose
The call buttons appear automatically —
CometChatMessageHeader detects that calling is enabled, so no extra code is needed.
To react to calls in your own code (a badge, analytics, refreshing a screen), listen on the Calls SDK with
CometChatCalls.addIncomingCallListener, the same callback the UI Kit uses internally. Do not use the Chat SDK’s CallListener; it is superseded and fires nothing in this flow.
Placing a call from your own screen
CometChatCallActivity is com.cometchat.uikit.kotlin.calls.CometChatCallActivity for XML Views and com.cometchat.uikit.compose.calls.CometChatCallActivity for Compose. initiateUserCall fails with CALL_IN_PROGRESS while another start is in flight; it does not check for a call already in progress, so do that yourself, or use Call Buttons, which refuse with ACTIVE_CALL while another session is active.
Styling the incoming-call screen
The incoming-call screen belongs to the Push SDK, which draws it even when your app is not running, so it cannot read the UI Kit theme at that moment. Instead you pass it your UI Kit theme once, as aCometChatPNIncomingCallTheme, when you initialise push. Light and dark are both included, and the screen and the call notifications then follow your theme.
The UI Kit reads its own theme into a CometChatIncomingCallTheme:
- Kotlin (XML Views)
- Jetpack Compose
calls/IncomingCallTheme.kt
CometChatPushNotifications.setIncomingCallTheme(context, theme).
Each field comes from one UI Kit colour:
Without this line, the screen still uses the UI Kit’s default colours. The UI Kit overrides the
cometchat_pn_call_* colour resources with its light and dark palette at build time. Those overrides win over the Push SDK’s defaults only when your app lists the UI Kit dependency before the Push SDK artifacts. Your app’s own overrides always win.
To change a single colour, override its resource, or chain any CometChatPNIncomingCallTheme.Colors.Builder setter after mapping. The full list of colours, strings, drawables and the layout is under Theming the SDK’s incoming-call screen. To draw the screen yourself, register your own activity with setIncomingCallActivity, for example one that hosts the deprecated Incoming Call component. The UI Kit’s CometChatCallActivity does not work there: it does not read the call the Push SDK passes in its intent, so it would open empty.
Upgrading from an app that used CometChat.addCallListener
Remove the Application-level CallListener, the incoming-call overlay or launchIncomingCallScreen call, any ringtone you played, the busy check, and the Push SDK 1.0 setVoIPEnabled / setOnCallAnsweredHandler wiring, and follow the steps above. The method-by-method mapping is on Migrating from Legacy Ringing.