> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-agent-in-group-react-v6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Incoming Call

> Incoming Call — CometChat documentation.

The `Incoming call` is a [Component](/ui-kit/react-native/v4/components-overview#components) 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.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/aivwqvtoO_fTqj20/images/f2b0315b-inoming_call_overview_cometchat_screens-68e564f3626b09262ae231fb2b42fabc.png?fit=max&auto=format&n=aivwqvtoO_fTqj20&q=85&s=8063eed2a784ab96820826eb16df1641" alt="Image" width="4498" height="3120" data-path="images/f2b0315b-inoming_call_overview_cometchat_screens-68e564f3626b09262ae231fb2b42fabc.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/dvwKpKGankGygs5o/images/66620137-inoming_call_overview_cometchat_screens-931541b638571df999e75442bed4acef.png?fit=max&auto=format&n=dvwKpKGankGygs5o&q=85&s=8daf0afa2837042eb55f455d7c169822" alt="Image" width="4498" height="3120" data-path="images/66620137-inoming_call_overview_cometchat_screens-931541b638571df999e75442bed4acef.png" />
  </Tab>
</Tabs>

The `Incoming Call` is comprised of the following base components:

| Components                                               | Description                                                                                                                                    |
| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [cometchat-list-item](/ui-kit/react-native/v4/list-item) | This component’s view consists of avatar, status indicator , title, and subtitle. The fields are then mapped with the SDK’s user, group class. |
| [cometchat-avatar](/ui-kit/react-native/v4/avatar)       | This component component displays an image or user's avatar with fallback to the first two letters of the username                             |

## Usage

### Integration

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    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);
              }}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

### Actions

[Actions](/ui-kit/react-native/v4/components-overview#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.

##### 1. 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.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    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}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

##### 2. 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.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    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}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

##### 3. onError

This action doesn't change the behavior of the component but rather listens for any errors that occur in the Banned Members component.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    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}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

***

### 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 `Incoming Call` component does not have any exposed filters.

### Events

[Events](/ui-kit/react-native/v4/components-overview#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.       |

<Tabs>
  <Tab title="Adding Listeners">
    ```tsx theme={null}
    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
      },
    });
    ```
  </Tab>
</Tabs>

***

<Tabs>
  <Tab title="Removing Listeners">
    ```tsx theme={null}
    import { CometChatUIEventHandler } from "@cometchat/chat-uikit-react-native";

    CometChatUIEventHandler.removeCallListener("CALL_LISTENER_ID");
    ```
  </Tab>
</Tabs>

***

## Customization

To fit your app's design requirements, you can customize the appearance of the Incoming Call 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.

##### 1. IncomingCall Style

To customize the appearance, you can assign a `IncomingCallStyle` object to the `Incoming Call` component.

In this example, we are employing the `IncomingCallStyle`.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/fW0PxkjcCIs_jips/images/d63297b3-inoming_call_style_cometchat_screens-295f886ff2e7d67de1b5e8d8df18230b.png?fit=max&auto=format&n=fW0PxkjcCIs_jips&q=85&s=a8b67e9bf893dd239dd162ae55ea277f" alt="Image" width="4498" height="3120" data-path="images/d63297b3-inoming_call_style_cometchat_screens-295f886ff2e7d67de1b5e8d8df18230b.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/wITpHRGFWGJvJnmU/images/eb39fa9d-inoming_call_style_cometchat_screens-529ea08252ced1af125ed866853fc989.png?fit=max&auto=format&n=wITpHRGFWGJvJnmU&q=85&s=bc1571d58c8ea80d4aa26028d9afb829" alt="Image" width="4498" height="3120" data-path="images/eb39fa9d-inoming_call_style_cometchat_screens-529ea08252ced1af125ed866853fc989.png" />
  </Tab>
</Tabs>

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatIncomingCall,
      IncomingCallStyleInterface,
    } 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 incomingCallStyle: IncomingCallStyleInterface = {
        declineButtonTextColor: "red",
        acceptButtonTextColor: "#6851D6",
      };

      return (
        <>
          {callReceived && (
            <CometChatIncomingCall
              call={incomingCall.current!}
              onDecline={(call) => {
                setCallReceived(false);
              }}
              incomingCallStyle={incomingCallStyle}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

The following properties are exposed by IncomingCallStyle:

| Property                         | Description                                             | Code                                          |
| -------------------------------- | ------------------------------------------------------- | --------------------------------------------- |
| **border**                       | Used to set border                                      | `border?: BorderStyleInterface,`              |
| **borderRadius**                 | Used to set border radius                               | `borderRadius?: number;`                      |
| **backgroundColor**              | Used to set background colour                           | `background?: string;`                        |
| **height**                       | Used to set height                                      | `height?: number` \| `string;`                |
| **width**                        | Used to set width                                       | `width?: number` \| `string;`                 |
| **titleFont**                    | Used to customise the font of the title in the app bar  | `titleFont?: FontStyleInterface;`             |
| **titleColor**                   | Used to customise the color of the title in the app bar | `titleColor?: string;`                        |
| **subtitleColor**                | Used to set the color for group item subtitle           | `subtitleColor?: string;`                     |
| **subtitleFont**                 | Used to set the font style for group item subtitle      | `subtitle Font?: FontStyleInterface;`         |
| **onlineStatusColor**            | Used to set online status color                         | `onlineStatusColor?: string;`                 |
| **acceptButtonTextColor**        | Used to set accept button text color                    | `acceptButtonTextColor?: string;`             |
| **acceptButtonTextFont**         | Used to set accept button text font                     | `acceptButtonTextFont?: FontStyleInterface;`  |
| **acceptButtonBackgroundColor**  | Used to set accept button background color              | `acceptButtonBackgroundColor?: string;`       |
| **acceptButtonBorder**           | Used to set accept button border                        | `acceptButtonBorder?: BorderStyleInterface;`  |
| **declineButtonTextColor**       | Used to set decline button text color                   | `declineButtonTextColor?: string;`            |
| **declineButtonTextFont**        | Used to set decline button text font                    | `declineButtonTextFont?: FontStyleInterface;` |
| **declineButtonBackgroundColor** | Used to set decline button background color             | `declineButtonBackgroundColor?: string;`      |
| **declineButtonBorder**          | Used to set decline button border                       | `declineButtonBorder?: BorderStyleInterface;` |

##### 2. Avatar Style

If you want to apply customized styles to the `Avatar` component within the `Incoming Call` Component, you can use the following code snippet. For more information you can refer [Avatar Styles](/ui-kit/react-native/v4/avatar#avatarstyleinterface).

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatIncomingCall,
      AvatarStyleInterface,
      BorderStyleInterface,
    } 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 borderStyle: BorderStyleInterface = {
        borderWidth: 10,
        borderStyle: "solid",
        borderColor: "#cc5e95",
      };

      const avatarStyle: AvatarStyleInterface = {
        outerViewSpacing: 5,
        outerView: {
          borderWidth: 2,
          borderStyle: "dotted",
          borderColor: "blue",
        },
        border: borderStyle,
      };

      return (
        <>
          {callReceived && (
            <CometChatIncomingCall
              call={incomingCall.current!}
              onDecline={(call) => {
                setCallReceived(false);
              }}
              avatarStyle={avatarStyle}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

##### 3. OngoingCallScreen Style

You can use this style property to apply customized styles to the `OngoingCallScreen` component within the `Incoming Call` Component.

***

### 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.

Here is a code snippet demonstrating how you can customize the functionality of the `Incoming Call` component.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    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);
              }}
              acceptButtonText="Answer"
              declineButtonText="Reject"
              disableSoundForCalls={true}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/FQNeiVxajtzWdB3i/images/b4ce1c06-inoming_call_func_cometchat_screens-bb2a41771b159d855dcf978d170604d3.png?fit=max&auto=format&n=FQNeiVxajtzWdB3i&q=85&s=e50399c260c296e4cbf1de40c7d99fcb" alt="Image" width="4498" height="3120" data-path="images/b4ce1c06-inoming_call_func_cometchat_screens-bb2a41771b159d855dcf978d170604d3.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/VF5v8Yrr3_dtKi2l/images/28d7d77c-inoming_call_func_cometchat_screens-2102724a47494f983aad06fe1d0b8a86.png?fit=max&auto=format&n=VF5v8Yrr3_dtKi2l&q=85&s=341eca0c8b2779e81a96e1c27099d329" alt="Image" width="4498" height="3120" data-path="images/28d7d77c-inoming_call_func_cometchat_screens-2102724a47494f983aad06fe1d0b8a86.png" />
  </Tab>
</Tabs>

Below is a list of customizations along with corresponding code snippets

| Property                 | Description                                                                       | Code                             |
| ------------------------ | --------------------------------------------------------------------------------- | -------------------------------- |
| **title**                | Used to set title                                                                 | `title?: string`                 |
| **acceptButtonText**     | Used to set custom accept button text                                             | `acceptButtonText?: string`      |
| **declineButtonText**    | Used to set custom decline button text                                            | `declineButtonText?: string`     |
| **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`  |
| **call**                 | CometChat call object consumed by the component to launch itself                  | `disableSoundForMessages={true}` |

***

### 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.

***

#### SubtitleView

By using the `SubtitleView` property, you can modify the SubtitleView to meet your specific needs.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/JoK2O2F7IYCQF1_g/images/1ee1d61f-inoming_call_subtitle_cometchat_screens-c63cdb7b1fe5284e920b350a4f544474.png?fit=max&auto=format&n=JoK2O2F7IYCQF1_g&q=85&s=bafcfffc8d7129bf364ce9ae28abf6fa" alt="Image" width="4498" height="3120" data-path="images/1ee1d61f-inoming_call_subtitle_cometchat_screens-c63cdb7b1fe5284e920b350a4f544474.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/wITpHRGFWGJvJnmU/images/ec1a435b-inoming_call_subtitle_cometchat_screens-8c41f12833dee15a84c74babe105247b.png?fit=max&auto=format&n=wITpHRGFWGJvJnmU&q=85&s=479afed53d83bb8bf0529866e522824a" alt="Image" width="4498" height="3120" data-path="images/ec1a435b-inoming_call_subtitle_cometchat_screens-8c41f12833dee15a84c74babe105247b.png" />
  </Tab>
</Tabs>

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    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 getSubtitleView = (call: CometChat.Call | CometChat.CustomMessage) => {
        return (
          <Text
            style={{
              fontSize: 15,
              color: "red",
              shadowColor: "red",
            }}
          >
            Custom Subtitle
          </Text>
        );
      };

      return (
        <>
          {callReceived && (
            <CometChatIncomingCall
              call={incomingCall.current!}
              onDecline={(call) => {
                setCallReceived(false);
              }}
              SubtitleView={getSubtitleView}
            />
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>
