Incoming Call
Overview
The CometChatIncomingCall
is a Component that serves as a visual representation when the user receives an incoming call, such as a voice call or video call, providing options to answer or decline the call.

Usage
Integration
CometChatIncomingCall
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.
- App.tsx
import { CometChat } from "@cometchat/chat-sdk-react-native";
import { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
function App(): React.JSX.Element {
const incomingCall = useRef(null);
const [callReceived, setCallReceived] = useState(false);
const listnerID = "UNIQUE_LISTENER_ID";
useEffect(() => {
//code
CometChat.addCallListener(
listnerID,
new CometChat.CallListener({
onIncomingCallReceived: (call) => {
incomingCall.current = call;
setCallReceived(true);
},
onOutgoingCallRejected: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
onIncomingCallCancelled: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
})
);
});
return (
<>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
/>
)}
</>
);
}
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.
onAccept
onAccept
is triggered when you click the accept button of the Incoming Call
component. You can override this action using the following code snippet.
- App.tsx
import { CometChat } from "@cometchat/chat-sdk-react-native";
import { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
function App(): React.JSX.Element {
const incomingCall = useRef(null);
const [callReceived, setCallReceived] = useState(false);
const listnerID = "UNIQUE_LISTENER_ID";
useEffect(() => {
//code
CometChat.addCallListener(
listnerID,
new CometChat.CallListener({
onIncomingCallReceived: (call) => {
incomingCall.current = call;
setCallReceived(true);
},
onOutgoingCallRejected: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
onIncomingCallCancelled: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
})
);
});
const onAcceptHandler = (message: CometChat.BaseMessage) => {
//code
};
return (
<>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
onAccept={onAcceptHandler}
/>
)}
</>
);
}
onDecline
onDecline
is triggered when you click the Decline button of the Incoming Call
component. This action does not have a predefined behavior. You can override this action using the following code snippet.
- App.tsx
import { CometChat } from "@cometchat/chat-sdk-react-native";
import { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
function App(): React.JSX.Element {
const incomingCall = useRef(null);
const [callReceived, setCallReceived] = useState(false);
const listnerID = "UNIQUE_LISTENER_ID";
useEffect(() => {
//code
CometChat.addCallListener(
listnerID,
new CometChat.CallListener({
onIncomingCallReceived: (call) => {
incomingCall.current = call;
setCallReceived(true);
},
onOutgoingCallRejected: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
onIncomingCallCancelled: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
})
);
});
const onDeclineHandler = (call) => {
setCallReceived(false);
};
return (
<>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={onDeclineHandler}
/>
)}
</>
);
}
onError
This action doesn't change the behavior of the component but rather listens for any errors that occur in the Banned Members component.
- App.tsx
import { CometChat } from "@cometchat/chat-sdk-react-native";
import { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
function App(): React.JSX.Element {
const incomingCall = useRef(null);
const [callReceived, setCallReceived] = useState(false);
const listnerID = "UNIQUE_LISTENER_ID";
useEffect(() => {
//code
CometChat.addCallListener(
listnerID,
new CometChat.CallListener({
onIncomingCallReceived: (call) => {
incomingCall.current = call;
setCallReceived(true);
},
onOutgoingCallRejected: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
onIncomingCallCancelled: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
})
);
});
const onErrorHandler = (error: CometChat.CometChatException) => {
//code
};
return (
<>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
onError={onErrorHandler}
/>
)}
</>
);
}
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 IncomingCall 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.
Event | Description |
---|---|
ccCallRejected | This event is triggered when the initiated call is rejected by the receiver. |
ccCallAccepted | This event is triggered when the initiated call is accepted by the receiver. |
ccCallEnded | This event is triggered when the initiated call successfully ends. |
ccCallFailled | This event is triggered when an error occurs during the intiated call. |
- Adding Listeners
import { CometChatUIEventHandler } from "@cometchat/chat-uikit-react-native";
CometChatUIEventHandler.addCallListener("CALL_LISTENER_ID", {
ccCallRejected: ({ call }) => {
//code
},
});
CometChatUIEventHandler.addCallListener("CALL_LISTENER_ID", {
ccCallAccepted: ({ call }) => {
//code
},
});
CometChatUIEventHandler.addCallListener("CALL_LISTENER_ID", {
ccCallEnded: ({ call }) => {
//code
},
});
CometChatUIEventHandler.addCallListener("CALL_LISTENER_ID", {
ccCallFailled: ({ call }) => {
//code
},
});
- Removing Listeners
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.
You can customize the appearance of the IncomingCall
Component by applying the IncomingCallStyle
to it using the following code snippet.
import {
CometChatIncomingCall,
CometChatThemeProvider,
} from "@cometchat/chat-uikit-react-native";
//code
return (
<SafeAreaView style={{ flex: 1 }}>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
style={{
containerStyle: {
backgroundColor: theme.color.extendedPrimary100,
},
avatarStyle: {
containerStyle: {
backgroundColor: theme.color.extendedPrimary500,
borderRadius: 8,
},
imageStyle: {
borderRadius: 8,
},
},
declineCallButtonStyle: {
backgroundColor: theme.color.staticWhite,
},
declineCallTextStyle: {
color: theme.color.error,
},
acceptCallButtonStyle: {
backgroundColor: theme.color.primary,
},
}}
/>
)}
</SafeAreaView>
);

Functionality
In this example, we're enhancing the interface by customizing the accept and decline button icons. By setting custom icons for both the accept and decline buttons, users can enjoy a more visually appealing and personalized experience.
Below is a list of customizations along with corresponding code snippets
Property | Description | Code |
---|---|---|
call | CometChat call object consumed by the component to launch itself | disableSoundForMessages={true} |
customSoundForCalls | Used to set custom sound for incoming calls | customSoundForCalls?: string |
disableSoundForCalls | Used to disable/enable the sound of incoming calls, by default it is set to false | disableSoundForCalls?: string |
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.
ItemView
Allows setting a custom view for rendering each conversation item in the fetched list.
Use Cases:
- Customize the call card UI for incoming calls.
- Display additional user details (e.g., caller ID, location).
- Integrate custom animations for call alerts.
import { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
import { CometChat } from "@cometchat/chat-sdk-react-native";
//code
return (
<SafeAreaView style={{ flex: 1 }}>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
ItemView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return JSX;
}}
/>
)}
</SafeAreaView>
);
LeadingView
Customizes the leading section of the component, usually the caller’s avatar or profile picture.
Use Cases:
- Display a profile picture with call status effects.
- Show a custom ringing animation around the avatar.
- Replace the avatar with a caller ID card.
import { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
import { CometChat } from "@cometchat/chat-sdk-react-native";
//code
return (
<SafeAreaView style={{ flex: 1 }}>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
LeadingView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return JSX;
}}
/>
)}
</SafeAreaView>
);
TitleView
Allows setting a custom title view, typically used for the caller’s name or call type.
Use Cases:
- Display the caller’s full name with a verified badge.
- Indicate the call type (Voice Call, Video Call).
- Show real-time status ("Ringing...", "Call from Work Contact", etc.).
import { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
import { CometChat } from "@cometchat/chat-sdk-react-native";
//code
return (
<SafeAreaView style={{ flex: 1 }}>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
TitleView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return JSX;
}}
/>
)}
</SafeAreaView>
);
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 { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
import { CometChat } from "@cometchat/chat-sdk-react-native";
//code
return (
<SafeAreaView style={{ flex: 1 }}>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
SubtitleView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return JSX;
}}
/>
)}
</SafeAreaView>
);
TrailingView
Customizes the trailing section for actions or additional call-related UI elements.
Use Cases:
- Add custom accept/reject buttons.
- Show a mute button before answering.
- Display a text response option (e.g., "Can’t talk now")
import { CometChatIncomingCall } from "@cometchat/chat-uikit-react-native";
import { CometChat } from "@cometchat/chat-sdk-react-native";
//code
return (
<SafeAreaView style={{ flex: 1 }}>
{callReceived && (
<CometChatIncomingCall
call={incomingCall.current!}
onDecline={(call) => {
setCallReceived(false);
}}
TrailingView={(call: CometChat.Call | CometChat.CustomMessage) => {
//return JSX;
}}
/>
)}
</SafeAreaView>
);