Skip to main content
This is a beta version. Features and documentation may change.
Version: v5

Outgoing Call

Overview

The CometChatOutgoingCall Component is a visual representation of a user-initiated call, whether it's a voice or video call. It serves as an interface for managing outgoing calls, providing users with essential options to control the call experience. This component typically includes information about the call recipient, call controls for canceling the call, and feedback on the call status, such as indicating when the call is in progress.

Image

Usage

Integration

CometChatOutgoingCall being a custom component, offers versatility in its integration. It can be seamlessly launched via button clicks or any user-triggered action, enhancing the overall user experience and facilitating smoother interactions within the application.

import { CometChat } from "@cometchat/chat-sdk-react-native";
import {
CometChatOutgoingCall,
CometChatUiKitConstants,
} from "@cometchat/chat-uikit-react-native";

function App(): React.JSX.Element {
const [call, setCall] = useState<CometChat.Call>();

useEffect(() => {
//login
const callObject = new CometChat.Call(
"receiver-uid",
CometChatUiKitConstants.MessageTypeConstants.audio,
CometChatUiKitConstants.ReceiverTypeConstants.user
);

CometChat.initiateCall(callObject)
.then((c) => {
setCall(c);
})
.catch(console.log);
}, []);

return <>{call && <CometChatOutgoingCall call={call} />}</>;
}

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

onEndCallButtonPressed

The onEndCallButtonPressed action is typically triggered when the end call button is pressed, carrying out default actions. However, with the following code snippet, you can effortlessly customize or override this default behavior to meet your specific needs.

import { CometChat } from "@cometchat/chat-sdk-react-native";
import {
CometChatOutgoingCall,
CometChatUiKitConstants,
} from "@cometchat/chat-uikit-react-native";

function App(): React.JSX.Element {
const [call, setCall] = useState<CometChat.Call>();

useEffect(() => {
//login
const callObject = new CometChat.Call(
"receiver-uid",
CometChatUiKitConstants.MessageTypeConstants.audio,
CometChatUiKitConstants.ReceiverTypeConstants.user
);

CometChat.initiateCall(callObject)
.then((c) => {
setCall(c);
})
.catch(console.log);
}, []);

const cancelCall = (c: CometChat.Call) => {
//code
CometChat.endCall(c.getSessionId()).then(() => {
setCall(undefined);
});
};

return (
<>
{call && (
<CometChatOutgoingCall
call={call}
onEndCallButtonPressed={cancelCall}
/>
)}
</>
);
}

Filters

Filters allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

The OutgoingCall component does not have any exposed filters.


Events

Events are emitted by a Component. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

The list of events emitted by the Incoming Call component is as follows.

EventDescription
ccCallEndedThis event is triggered when the initiated call successfully ends.
ccCallFailledThis event is triggered when an error occurs during the intiated call.
import { CometChatUIEventHandler } from "@cometchat/chat-uikit-react-native";

CometChatUIEventHandler.addCallListener("CALL_LISTENER_ID", {
ccCallEnded: ({ call }) => {
//code
},
});

CometChatUIEventHandler.addCallListener("CALL_LISTENER_ID", {
ccCallFailled: ({ call }) => {
//code
},
});

import { CometChatUIEventHandler } from "@cometchat/chat-uikit-react-native";

CometChatUIEventHandler.removeCallListener("CALL_LISTENER_ID");

Customization

To fit your app's design requirements, you can customize the appearance of the conversation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.

import { CometChat } from "@cometchat/chat-sdk-react-native";
import {
CometChatOutgoingCall,
CometChatUiKitConstants,
} from "@cometchat/chat-uikit-react-native";

function App(): React.JSX.Element {
const [call, setCall] = useState<CometChat.Call>();

useEffect(() => {
//login
const callObject = new CometChat.Call(
"receiver-uid",
CometChatUiKitConstants.MessageTypeConstants.audio,
CometChatUiKitConstants.ReceiverTypeConstants.user
);

CometChat.initiateCall(callObject)
.then((c) => {
setCall(c);
})
.catch(console.log);
}, []);

const cancelCall = (c: CometChat.Call) => {
//code
CometChat.endCall(c.getSessionId()).then(() => {
setCall(undefined);
});
};

return (
<>
{call && (
<CometChatOutgoingCall
call={call}
onEndCallButtonPressed={cancelCall}
style={{
avatarStyle: {
containerStyle: {
borderRadius: 8,
},
imageStyle: {
borderRadius: 8,
},
},
endCallButtonStyle: {
borderRadius: 8,
},
}}
/>
)}
</>
);
}
Image

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

Below is a list of customizations along with corresponding code snippets

MethodsDescriptionCode
callSets the call object for CometChatOutgoingCallcall?: CometChat.Call | CometChat.CustomMessage
callSettingsBuilderSets the CallSettingsBuilder for the outgoing call configuration.callSettingsBuilder={callSettingsBuilderObject}
customSoundForCallsUsed to set custom sound for callscustomSoundForCalls?: string
disableSoundForCallsUsed to disable/enable the sound of Outgoing calls, by default it is set to falsedisableSoundForCalls?: boolean

Advanced

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.

TitleView

Allows setting a custom list item view to be rendered for each conversation in the fetched call list.

Use Cases:

  • Display the contact’s name in a unique style.
  • Show a call type indicator (Voice Call, Video Call).
  • Add status text like "Calling..." or "Ringing...".
import { CometChat } from "@cometchat/chat-sdk-react-native";
import {
CometChatOutgoingCall,
CometChatUiKitConstants,
} from "@cometchat/chat-uikit-react-native";

function App(): React.JSX.Element {
const [call, setCall] = useState<CometChat.Call>();

useEffect(() => {
//login
const callObject = new CometChat.Call(
"receiver-uid",
CometChatUiKitConstants.MessageTypeConstants.audio,
CometChatUiKitConstants.ReceiverTypeConstants.user
);

CometChat.initiateCall(callObject)
.then((c) => {
setCall(c);
})
.catch(console.log);
}, []);

const cancelCall = (c: CometChat.Call) => {
//code
CometChat.endCall(c.getSessionId()).then(() => {
setCall(undefined);
});
};

return (
<>
{call && (
<CometChatOutgoingCall
call={call}
onEndCallButtonPressed={cancelCall}
TitleView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return jsx;
}}
/>
)}
</>
);
}

SubtitleView

Enables customizing the subtitle view, typically used for additional call details.

Use Cases:

  • Display call duration if available.
  • Show network strength indicators.
  • Include a custom message like "Connecting...".
import { CometChat } from "@cometchat/chat-sdk-react-native";
import {
CometChatOutgoingCall,
CometChatUiKitConstants,
} from "@cometchat/chat-uikit-react-native";

function App(): React.JSX.Element {
const [call, setCall] = useState<CometChat.Call>();

useEffect(() => {
//login
const callObject = new CometChat.Call(
"receiver-uid",
CometChatUiKitConstants.MessageTypeConstants.audio,
CometChatUiKitConstants.ReceiverTypeConstants.user
);

CometChat.initiateCall(callObject)
.then((c) => {
setCall(c);
})
.catch(console.log);
}, []);

const cancelCall = (c: CometChat.Call) => {
//code
CometChat.endCall(c.getSessionId()).then(() => {
setCall(undefined);
});
};

return (
<>
{call && (
<CometChatOutgoingCall
call={call}
onEndCallButtonPressed={cancelCall}
SubtitleView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return jsx;
}}
/>
)}
</>
);
}

AvatarView

Allows setting a custom leading view, usually used for the contact’s profile picture or avatar.

Use Cases:

  • Show a profile picture with an online indicator.
  • Display a custom icon based on the call type (Voice/Video).
  • Use an animated ring effect around the avatar when calling.
import { CometChat } from "@cometchat/chat-sdk-react-native";
import {
CometChatOutgoingCall,
CometChatUiKitConstants,
} from "@cometchat/chat-uikit-react-native";

function App(): React.JSX.Element {
const [call, setCall] = useState<CometChat.Call>();

useEffect(() => {
//login
const callObject = new CometChat.Call(
"receiver-uid",
CometChatUiKitConstants.MessageTypeConstants.audio,
CometChatUiKitConstants.ReceiverTypeConstants.user
);

CometChat.initiateCall(callObject)
.then((c) => {
setCall(c);
})
.catch(console.log);
}, []);

const cancelCall = (c: CometChat.Call) => {
//code
CometChat.endCall(c.getSessionId()).then(() => {
setCall(undefined);
});
};

return (
<>
{call && (
<CometChatOutgoingCall
call={call}
onEndCallButtonPressed={cancelCall}
AvatarView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return jsx;
}}
/>
)}
</>
);
}

EndCallView

Defines a custom title view for the end call button, allowing modifications to the call termination UI.

Use Cases:

  • Customize the "End Call" button style.
  • Add a confirmation pop-up before ending the call.
  • Display different icons based on call status (Active, On Hold).
import { CometChat } from "@cometchat/chat-sdk-react-native";
import {
CometChatOutgoingCall,
CometChatUiKitConstants,
} from "@cometchat/chat-uikit-react-native";

function App(): React.JSX.Element {
const [call, setCall] = useState<CometChat.Call>();

useEffect(() => {
//login
const callObject = new CometChat.Call(
"receiver-uid",
CometChatUiKitConstants.MessageTypeConstants.audio,
CometChatUiKitConstants.ReceiverTypeConstants.user
);

CometChat.initiateCall(callObject)
.then((c) => {
setCall(c);
})
.catch(console.log);
}, []);

const cancelCall = (c: CometChat.Call) => {
//code
CometChat.endCall(c.getSessionId()).then(() => {
setCall(undefined);
});
};

return (
<>
{call && (
<CometChatOutgoingCall
call={call}
onEndCallButtonPressed={cancelCall}
EndCallView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return jsx;
}}
/>
)}
</>
);
}