Implement incoming and outgoing call notifications with accept/reject functionality. Ringing enables real-time call signaling between users, allowing them to initiate calls and respond to incoming call requests.
Ringing functionality requires the CometChat Chat SDK to be integrated alongside the Calls SDK. The Chat SDK handles call signaling (initiating, accepting, rejecting calls), while the Calls SDK manages the actual call session.
How Ringing Works
The ringing flow involves two SDKs working together:
- Chat SDK - Handles call signaling (initiate, accept, reject, cancel)
- Calls SDK - Manages the actual call session once accepted
Initiate a Call
Use the Chat SDK to initiate a call to a user or group:
Kotlin
Kotlin (with Timeout)
Java
Java (with Timeout)
| Parameter | Type | Description |
|---|
receiverID | String | UID of the user or GUID of the group to call |
receiverType | String | CometChatConstants.RECEIVER_TYPE_USER or RECEIVER_TYPE_GROUP |
callType | String | CometChatConstants.CALL_TYPE_VIDEO or CALL_TYPE_AUDIO |
timeout | int | Optional. The timeout duration in seconds for the call to be answered before it’s automatically cancelled. Defaults to 45 seconds. |
Listen for Incoming Calls
Register a call listener to receive incoming call notifications:
| Callback | Description |
|---|
onIncomingCallReceived | A new incoming call is received |
onOutgoingCallAccepted | The receiver accepted your outgoing call |
onOutgoingCallRejected | The receiver rejected your outgoing call |
onIncomingCallCancelled | The caller cancelled the incoming call |
onCallEndedMessageReceived | The call has ended |
Remember to remove the call listener when it’s no longer needed to prevent memory leaks:
Accept a Call
When an incoming call is received, accept it using the Chat SDK:
Reject a Call
Reject an incoming call:
Cancel a Call
Cancel an outgoing call before it’s answered:
Join the Call Session
After accepting a call (or when your outgoing call is accepted), join the call session using the Calls SDK:
For more details on session customization and controlling the call, see Actions and Listeners.
End a Call
Properly ending a call requires coordination between both SDKs to ensure all participants are notified and call logs are recorded correctly.
Always call CometChat.endCall() when ending a call. This notifies the other participant and ensures the call is properly logged. Without this, the other user won’t know the call has ended and call logs may be incomplete.
When using the default call UI, listen for the end call button click using ButtonClickListener and call endCall():
The other participant receives onCallEndedMessageReceived callback and should leave the session:
Call Status Values
| Status | Description |
|---|
initiated | Call has been initiated but not yet answered |
ongoing | Call is currently in progress |
busy | Receiver is busy on another call |
rejected | Receiver rejected the call |
cancelled | Caller cancelled before receiver answered |
ended | Call ended normally |
missed | Receiver didn’t answer in time |
unanswered | Call was not answered |