Calls / React Native
Calls React Native v1
Calls React Native
Calls
React Native
Home
/
Calls
/
React Native
/
Direct call

Receive a call

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();
  },
});