> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-feature-card-builder.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Join Protected Group

> Join Protected Group — CometChat documentation.

## Overview

`CometChatJoinGroup` is a [Component](/ui-kit/react-native/v4/components-overview#components) used to set up a screen that shows the functionality to join a password protected group, featuring the functionality to join a password-protected group, where users can join a single password-protected group at a time.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-feature-card-builder/eLHw5QGTFIHJKVut/images/66d8776e-protected_group_overview_cometchat_screens-9c7855b0c3dcc583e4cbcbbf1c803289.png?fit=max&auto=format&n=eLHw5QGTFIHJKVut&q=85&s=d48acdd0e831f7cadadbd978f2f6bf6c" alt="Image" width="4498" height="3120" data-path="images/66d8776e-protected_group_overview_cometchat_screens-9c7855b0c3dcc583e4cbcbbf1c803289.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-feature-card-builder/GQCy4V9W9Tf76kX8/images/4c36f856-protected_group_overview_cometchat_screens-db5e81fea712c033175a8ab363e8f00c.png?fit=max&auto=format&n=GQCy4V9W9Tf76kX8&q=85&s=09f0975b13f18f12a81a1d90cf75cec7" alt="Image" width="4498" height="3120" data-path="images/4c36f856-protected_group_overview_cometchat_screens-db5e81fea712c033175a8ab363e8f00c.png" />
  </Tab>
</Tabs>

***

## Usage

### Integration

The following code snippet illustrates how you can directly incorporate the Join Group component into your Application.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import { CometChatJoinProtectedGroup } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const [group, setGroup] = useState<CometChat.Group | undefined>(undefined);

      const getGroup = async () => {
        const group = await CometChat.getGroup("protected-group-id");
        setGroup(group);
      };

      useEffect(() => {
        //login
        getGroup();
      });

      return (
        <>
          {group && (
            <CometChatJoinProtectedGroup
              group={group}
            ></CometChatJoinProtectedGroup>
          )}
        </>
      );
    }
    ```
  </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. onJoinClick

The `onJoinClick` action is activated when you click the join Group button. This returns the join groups.

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 { CometChatJoinProtectedGroup } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const [group, setGroup] = useState<CometChat.Group | undefined>(undefined);

      const getGroup = async () => {
        const group = await CometChat.getGroup("protected-group-id");
        setGroup(group);
      };

      useEffect(() => {
        //login
        getGroup();
      });

      const onJoinClickHandler = ({
        group,
        password,
      }: {
        group: CometChat.Group;
        password: string;
      }) => {
        //code
      };

      return (
        <>
          {group && (
            <CometChatJoinProtectedGroup
              group={group}
              onJoinClick={onJoinClickHandler}
            ></CometChatJoinProtectedGroup>
          )}
        </>
      );
    }
    ```
  </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 `Join Group` 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.

Events emitted by the Join Group component is as follows.

| Event                   | Description                                                  |
| ----------------------- | ------------------------------------------------------------ |
| **ccGroupMemberJoined** | Triggers when the user joined a protected group successfully |

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

    CometChatUIEventHandler.addGroupListener("GROUP_LISTENER_ID", {
      ccGroupMemberJoined: ({ joinedGroup }) => {
        //code
      },
    });
    ```
  </Tab>
</Tabs>

***

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

    CometChatUIEventHandler.removeGroupListener("GROUP_LISTENER_ID");
    ```
  </Tab>
</Tabs>

***

## Customization

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

You can set the `JoinGroupStyle` to the `Join Group` Component to customize the styling.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-feature-card-builder/GQCy4V9W9Tf76kX8/images/4a16709b-protected_group_style_cometchat_screens-36ab60aa43613fa3ef0a798279a7227c.png?fit=max&auto=format&n=GQCy4V9W9Tf76kX8&q=85&s=6058878848a52e6aa6f89ffbebdb932a" alt="Image" width="4498" height="3120" data-path="images/4a16709b-protected_group_style_cometchat_screens-36ab60aa43613fa3ef0a798279a7227c.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-feature-card-builder/wEJh-uJMkapAxmr_/images/f793f1f1-protected_group_style_cometchat_screens-71ffbeab8ae0bd3d282d686ff0156aad.png?fit=max&auto=format&n=wEJh-uJMkapAxmr_&q=85&s=1bef12bbe84a17a6af3609cd3662ebca" alt="Image" width="4498" height="3120" data-path="images/f793f1f1-protected_group_style_cometchat_screens-71ffbeab8ae0bd3d282d686ff0156aad.png" />
  </Tab>
</Tabs>

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatJoinProtectedGroup,
      JoinProtectedGroupStyleInterface,
    } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const [group, setGroup] = useState<CometChat.Group | undefined>(undefined);

      const getGroup = async () => {
        const group = await CometChat.getGroup("protected-group-id");
        setGroup(group);
      };

      useEffect(() => {
        //login
        getGroup();
      });

      const joinProtectedGroupStyle: JoinProtectedGroupStyleInterface = {
        background: "#d2cafa",
        joinIconTint: "red",
        closeIconTint: "red",
      };

      return (
        <>
          {group && (
            <CometChatJoinProtectedGroup
              group={group}
              joinProtectedGroupStyle={joinProtectedGroupStyle}
            ></CometChatJoinProtectedGroup>
          )}
        </>
      );
    }
    ```
  </Tab>
</Tabs>

List of properties exposed by JoinGroupsStyle

| Property                     | Description                                                   | Code                                            |
| ---------------------------- | ------------------------------------------------------------- | ----------------------------------------------- |
| **border**                   | Used to set border                                            | `border?: BorderStyleInterface,`                |
| **borderRadius**             | Used to set border radius                                     | `borderRadius?: number;`                        |
| **background**               | Used to set background colour                                 | `background?: string;`                          |
| **height**                   | Used to set height                                            | `height?: string` \| `number ;`                 |
| **width**                    | Used to set width                                             | `width?: string` \| `number ;`                  |
| **descriptionTextStyle**     | Used to the set font style for the description                | `descriptionTextStyle?: FontStyleInterface`     |
| **errorTextStyle**           | Used to the set font style for the error text                 | `errorTextStyle?: FontStyleInterface`           |
| **passwordInputTextStyle**   | Used to the set font style for the password input             | `passwordInputTextStyle?: FontStyleInterface`   |
| **passwordPlaceholderStyle** | Used to the set font style for the password input placeholder | `passwordPlaceholderStyle?: FontStyleInterface` |

***

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

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import { CometChatJoinProtectedGroup } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      return (
        <CometChatJoinProtectedGroup
          title="Custom Title"
          passwordPlaceholderText="Custom text for password placeholder"
        />
      );
    }
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-feature-card-builder/F1NBmCh5qoHS2CIE/images/de8ee622-protected_group_func_cometchat_screens-b84123b272513b80e9f7f66ffd354343.png?fit=max&auto=format&n=F1NBmCh5qoHS2CIE&q=85&s=5105b621311f82cd95aff927b6c0212f" alt="Image" width="4498" height="3120" data-path="images/de8ee622-protected_group_func_cometchat_screens-b84123b272513b80e9f7f66ffd354343.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-feature-card-builder/sD1l8I7Yw1lyflGY/images/819e245c-protected_group_func_cometchat_screens-4a070a2937c3748d0191788b18d081dd.png?fit=max&auto=format&n=sD1l8I7Yw1lyflGY&q=85&s=f83e4122e7841839d4e32167189754a7" alt="Image" width="4498" height="3120" data-path="images/819e245c-protected_group_func_cometchat_screens-4a070a2937c3748d0191788b18d081dd.png" />
  </Tab>
</Tabs>

| Property                    | Description                                      | Code                                                                    |
| --------------------------- | ------------------------------------------------ | ----------------------------------------------------------------------- |
| **title**                   | Custom title for the component                   | `title='Your Custom Title'`                                             |
| **joinButtonText**          | Custom text for the join group button            | `joinButtonText='Your Custom Join Group Button Text'`                   |
| **passwordPlaceholderText** | Custom placeholder text for password input field | `passwordPlaceholderText='Your Custom Password Input Placeholder Text'` |
| **errorText**               | Custom error state text                          | `errorText='Your Custom Error Text'`                                    |
| **hasError**                | Whether the component has an error state         | `hasError={true}`                                                       |
| **group**                   | used to set the group                            | `group={groupObject}`                                                   |
| **description**             | Used to set Custom Description                   | `description='Custom Description'`                                      |

***

### Advance

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.

The `Join Group` component does not offer any advanced functionalities beyond this level of customization.

***
