CometChat offers developers two options for integrating voice and video calls into websites and mobile apps: Default Calling and Direct Calling. These provide distinct user experiences, similar to WhatsApp and Google Meet/Zoom respectively.
1. Default Calling
The Default Calling option allows for one-on-one calls, where users can accept or reject an incoming call, just like WhatsApp. This method requires the integration of both the CometChat Chat SDK and Calls SDK.
Steps for Integration:
- Set up the Chat SDK:
The Chat SDK is necessary to manage events like call initiation, acceptance, and rejection.
- Setting up and Initializing the SDK
- Logging into the SDKAfter these steps, you can perform CometChat operations using the SDK.
- Calling Workflow:
Let’s consider Alex as the caller and Bob as the receiver.
- Alex initiates the call using the initiateCall() method.
- Bob receives the call in the
onIncomingCallReceived()
method of theCallListener
. He can:- Accept the call using the acceptCall() method, or
- Reject the call using the rejectCall() method with a
rejected
status.
- Alex can cancel the call before it’s accepted using the rejectCall() method with a
cancelled
status. - If Bob accepts the call, the flow will move to the Calls SDK. For more information, please refer to point (3) below
For more detailed methods, visit: Default Calling Docs
- Calls SDK Setup:
Once the call is accepted, the interaction moves to the Calls SDK for the actual voice/video session. Steps to get started with the Calls SDK:
- Initialise the Calls SDK:
- Follow the setup guide: Initialise the Calls SDK
- Generate a Call Token:
- To generate a token for the user, use the Generate Call Token method.
- If you’re using the Chat SDK, you can obtain an
authToken
for the user via thegetAuthToken()
method. Alternatively, you can generate it using the REST API.
- Start the Call Session:
- Once the token is generated, call the
startSession()
method to begin the call. - In case of Default Call, the session id will be generated by CometChat and provided to you while initiating the call and via the events available in the CallListener.
- Once the token is generated, call the
2. Direct Calling
The Direct Calling option supports multi-user sessions with a shared session ID, similar to Google Meet or Zoom. This type of calling only requires the Calls SDK.
Steps for Integration:
- Initialise the Calls SDK:
- Follow the setup guide: Initialise the Calls SDK
- Generate a Call Token:
- To generate a token for the user, use the Generate Call Token method.
- If you’re using the Chat SDK, you can obtain an
authToken
for the user via thegetAuthToken()
method. Alternatively, you can generate it using the REST API.
- Start the Call Session:
- Once the token is generated, call the
startSession()
method to begin the call. - You will need to generate a unique session ID for this type of call, ensuring that all users connecting with the same ID join the same session.
With CometChat’s flexible options for Default Calling and Direct Calling, you can easily integrate one-on-one or group call functionalities, tailored to your application’s needs.
For more information, refer to the official CometChat SDK documentation.