Skip to main content

You are looking at Signaling v1.x Docs. The newest version is  Signaling 2.x

Android
iOS
Web
macOS
Windows
Linux C++
Linux Java
Unity
Version: 1.x

Call invitations

The Agora Signaling SDK supports the call invitation function, including the following behaviors in common call scenarios:

  • Caller: Sends or cancels a call invitation.

  • Callee: Accepts or refuses a call invitation.

1602314541995

The call invitation function provided by the Agora Signaling SDK only implements the basic control logic of the call invitation: sending, canceling, accepting, and refusing the call invitation. The Agora Signaling SDK does not handle operations after a callee accepts the invitation, nor does it manage the entire lifecycle. You must implement that yourself according to your requirements.

The call invitation can be applied to the following scenarios:

  • A call invitation requiring notification of an incoming call.

  • A screen-sharing scenario requiring call invitations.

  • A whiteboard-sharing scenario requiring a video call between two parties.

  • A call invitation requiring synchronizing the states of both parties.

Implementation

In a complete call invitation process, the call invitation states of the caller and the callee are defined by LocalInvitation and RemoteInvitation, respectively.

1602314550083

Send a call invitation

The steps to send a call invitation are as follows:

  1. The caller creates the LocalInvitation by calling createLocalInvitation; at the same time, the lifecycle of the LocalInvitation begins.

  2. The caller sends a call invitation by calling sendLocalInvitation. The lifecycle of the RemoteInvitation begins as the callee receives the onRemoteInvitationReceived callback, and then the caller receives the onLocalInvitationReceivedByPeer callback.

    The sample code for sending a call invitation is as follows:


    _10
    // Gets RtmCallManager instance
    _10
    RtmCallManager = RtmClient.getRtmCallManager();
    _10
    _10
    void inviteCall(final String peerUid, final String channel) {
    _10
    // Creates LocalInvitation
    _10
    LocalInvitation invitation = RtmCallManager.createLocalInvitation(peerUid);
    _10
    invitation.setContent(channel);
    _10
    // Sends call invitation
    _10
    RtmCallManager.sendLocalInvitation(invitation);
    _10
    }

Cancel a call invitation

The caller cancels the call invitation by calling cancelLocalInvitation. The lifecycle of the RemoteInvitation ends as the callee receives the onRemoteInvitationCanceled callback. And then the lifecycle of the LocalInvitation ends as the caller receives the onLocalInvitationCanceled callback.

img

The sample code for canceling a call invitation is as follows:


_6
// Cancel a call invitation.
_6
void cancelLocalInvitation() {
_6
if (RtmCallManager != null && invitation != null) {
_6
RtmCallManager.cancelLocalInvitation(invitation);
_6
}
_6
}

Accept a call invitation

The callee gets RemoteInvitation from onRemoteInvitationReceived and accepts the call invitation by calling acceptRemoteInvitation. The lifecycle of the RemoteInvitation ends as the caller receives the onRemoteInvitationAccepted callback. The lifecycle of the LocalInvitation ends as the caller receives the onLocalInvitationAccepted callback.

img

The sample code for accepting a call invitation is as follows:


_6
// Accept a call invitation.
_6
void answerCall(final RemoteInvitation invitation) {
_6
if (RtmCallManager != null && invitation != null) {
_6
RtmCallManager.acceptRemoteInvitation(invitation);
_6
}
_6
}

Refuse a call invitation

The callee gets RemoteInvitation from onRemoteInvitationReceived and refuses the call invitation by calling refuseRemoteInvitation. The lifecycle of the RemoteInvitation ends as the caller receives the onRemoteInvitationRefused callback. The lifecycle of the LocalInvitation ends as the caller receives the onLocalInvitationRefused callback.

img

The sample code for refusing a call invitation is as follows:


_6
// Refuse a call invitation.
_6
void refuseRemoteInvitation(@NonNull RemoteInvitation invitation) {
_6
if (RtmCallManager != null) {
_6
RtmCallManager.refuseRemoteInvitation(invitation);
_6
}
_6
}

API Reference

See Call invitation

Signaling