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

Add an event handler

Add event handlers for the client app to react to events that occur for the 1-to-1 call. Event handlers can detect device-specific events and call-specific events.

To detect device-specific events, add the onRinging event handler by registering the SendbirdCalls.setListener() method. After you’ve added the event handler, an incoming call is handled as shown below.

  onRinging(callProps: DirectCallProperties){
    // Processing incoming call.

To detect call-specific events, add the DirectCallListener event handler by using the DirectCall.addLitsener() method. To see a full list of call-related events, search DirectCallListener in the API Reference.

const unsubscribe = directCall.addListener({
 onEstablished: (call: DirectCallProperties) => {},

 onConnected: (call: DirectCallProperties) => {},

 onEnded: (call: DirectCallProperties) => {},

 onRemoteAudioSettingsChanged: (call: DirectCallProperties) => {},

 onRemoteVideoSettingsChanged: (call: DirectCallProperties) => {},

 // ...


When you want to remove listeners that are no longer in use, call unsubscribe() when you receive onEnded or when you perform cleanup for useEffect.