Overview
This section explains how to implement a complete calling workflow with ringing functionality, including incoming/outgoing call UI, call acceptance, rejection, and cancellation. Previously known as Default Calling.After the call is accepted, you need to start the call session. See the Call Session guide for details on starting and managing the actual call.
- Caller initiates a call using
initiateCall() - Receiver gets notified via
onIncomingCallReceived()callback - Receiver can either:
- Accept the call using
acceptCall() - Reject the call using
rejectCall()with status.rejected
- Accept the call using
- Caller can cancel the call using
rejectCall()with status.cancelled - Once accepted, both participants call
startSession()to join the call
Initiate Call
TheinitiateCall() method sends a call request to a user or a group. On success, the receiver gets an onIncomingCallReceived() callback.
- Swift
- Swift (with Timeout)
- Objective-C
Call Listeners
Register theCometChatCallDelegate to receive real-time call events.
- Swift
- Objective-C
Set your view controller as the CometChat call delegate in
viewDidLoad(): CometChat.calldelegate = selfEvents
Accept Call
When an incoming call is received viaonIncomingCallReceived(), use acceptCall() to accept it. On success, start the call session.
- Swift
- Objective-C
Reject Call
UserejectCall() to reject an incoming call. Set the status to .rejected.
- Swift
- Objective-C
Cancel Call
The caller can cancel an outgoing call before it’s answered usingrejectCall() with status .cancelled.
- Swift
- Objective-C
Start Call Session
Once the call is accepted, both participants need to start the call session. Caller flow: In theonOutgoingCallAccepted() callback, generate a token and start the session.
Receiver flow: In the acceptCall() success callback, generate a token and start the session.
- Swift
End Call
To end an active call in the ringing flow, the process differs based on who ends the call. User who ends the call: When the user presses the end call button, theonCallEndButtonPressed() callback is triggered. Inside this callback, call CometChat.endCall(). On success, call CometChat.clearActiveCall() and CometChatCalls.endSession().
- Swift
onCallEnded() callback):
- Swift
Busy Call Handling
If the receiver is already on another call, you can reject the incoming call with.busy status.
- Swift
- Objective-C