import { StreamVideoClient } from "@stream-io/video-react-native-sdk";
const client = StreamVideoClient.getOrCreateInstance({
apiKey,
tokenProvider,
user,
options: { rejectCallWhenBusy: true },
});
Reject call when busy
In this documentation article, we will explore how to setup automatic call rejection on callee side when callee is in another ringing call. Also we will show how this information can be presented on the caller side.
Reject call when busy
To enable this we need to configure the client with the option rejectCallWhenBusy
set to true
.
If rejectCallWhenBusy
is set to true
the call will be automatically rejected by the callee. The call rejected event will be attached with reason busy
.
In this case, on the caller side, the SDK will automatically play a busy tone sound. Additionally, you can opt to show a visual indication on the caller side that the callee is busy in another call.
The snippet below is an example of how we can show a alert dialog with a message from the call.rejected
event handler on our videoClient
:
import { useStreamVideoClient } from "@stream-io/video-react-native-sdk";
import { Alert } from "react-native";
const videoClient = useStreamVideoClient();
useEffect(() => {
if (!videoClient) return;
return videoClient?.on("call.rejected", async (event) => {
const isCallCreatedByMe =
event.call.created_by.id === _videoClient?.state.connectedUser?.id;
const calleeName = event.user.name ?? event.user.id;
const isCalleeBusy = isCallCreatedByMe && event.reason === "busy";
if (isCalleeBusy) {
Alert.alert("Call rejected", `User: ${calleeName} is busy.`);
}
});
}, [videoClient]);