- Alex initiates the call to Bob using the initiateCall() method.
-
Bob now has two choices:
- Accept the call from Alex using the acceptCall() method.
- Reject the call from Alex using the rejectCall() method passing the status as
rejected.
-
In the meantime, Alex has the option to cancel the call he initiated to Bob using the rejectCall() method passing the status as
cancelled. -
If Bob accepts the call from Alex, both Alex and Bob need to call the startCall() method. Alex in the onOutgoingCallAccepted() method of the
CallListenerand Bob in the success obtained from the acceptCall() method and both will be connected to each other.
Initiate Call
TheinitiateCall() method sends a call request to a user or a group.
- User Call
- Group Call
- User Call (Typescript)
- Group Call (Typescript)
Call class. The constructor for Call class takes the following parameters:
On successful initialization, a
Call object is returned with the details of the call including a unique session ID for the call.
Receive Calls
Wherever you wish to receive the call events in, you need to register theCallListener listener using the addCallListener() method. onCallEndedMessageReceived() event will receive when you trigger CometChat.endCall(sessionID).
- Receive Calls
- TypeScript
We recommend you remove the listener once the activity or fragment is not in use.
- Remove Call Listener
- TypeScript
- The receiver of the call accepts the call.
- The receiver of the call rejects the call.
- The initiator of the call cancels the call.
Accept the Incoming Call
Once you have received an incoming call from a user or in any group, to accept the call using theacceptCall() method.
- Accept Incoming Call
- TypeScript
Reject the Incoming Call
To reject the incoming call once it is received using therejectCall() method.
- Reject Incoming Call
- TypeScript
Here the status needs to be set as
CometChat.CALL_STATUS.REJECTED as the call is being rejected by the receiver of the call.
Cancel the Outgoing Call
In the case where the initiator wishes to cancel the call, use the same aboverejectCall() method and just pass the status to the rejectCall() method as CometChat.CALL_STATUS.CANCELLED
Start a Call
Once the call request is sent and the receiver has accepted the call, both the initiator and the receiver need to call thestartSession() method.