/ SDKs / React Native
SDKs
Calls SDKs React Native v1
Calls SDKs React Native
Calls SDKs
React Native
Version 1

Receive a call

Copy link

Register SendbirdCalls.setListener({ onRinging }) to receive incoming calls. Accept or decline incoming calls using the directCall.accept() or the directCall.end() methods. When you accept the call, a media session will automatically be established by the SDK.

Before accepting any calls, the DirectCall.addListener must be registered first in the SendbirdCalls.setListener({ onRinging }). Once registered, DirectCallListener enables reacting to in-call events through listener methods.

SendbirdCalls.setListener({
  async onRinging(callProps: DirectCallProperties) {
    const directCall = await SendbirdCalls.getDirectCall(callProps.callId);

    const unsubscribe = directCall.addListener({
      onEnded() {
        unsubscribe();
      },
    });

    directCall.accept();
  },
});