Skip to main content
Version: v4

Join Protected Group

Overview

CometChatJoinGroup is a Component 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.

Image

Usage

Integration

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

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>
)}
</>
);
}

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.

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.

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>
)}
</>
);
}

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

The Join Group 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.

Events emitted by the Join Group component is as follows.

EventDescription
ccGroupMemberJoinedTriggers when the user joined a protected group successfully
import { CometChatUIEventHandler } from "@cometchat/chat-uikit-react-native";

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

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

CometChatUIEventHandler.removeGroupListener("GROUP_LISTENER_ID");

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.

Image
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>
)}
</>
);
}

List of properties exposed by JoinGroupsStyle

PropertyDescriptionCode
borderUsed to set borderborder?: BorderStyleInterface,
borderRadiusUsed to set border radiusborderRadius?: number;
backgroundUsed to set background colourbackground?: string;
heightUsed to set heightheight?: string | number ;
widthUsed to set widthwidth?: string | number ;
descriptionTextStyleUsed to the set font style for the descriptiondescriptionTextStyle?: FontStyleInterface
errorTextStyleUsed to the set font style for the error texterrorTextStyle?: FontStyleInterface
passwordInputTextStyleUsed to the set font style for the password inputpasswordInputTextStyle?: FontStyleInterface
passwordPlaceholderStyleUsed to the set font style for the password input placeholderpasswordPlaceholderStyle?: 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.

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"
/>
);
}
Image
PropertyDescriptionCode
titleCustom title for the componenttitle='Your Custom Title'
joinButtonTextCustom text for the join group buttonjoinButtonText='Your Custom Join Group Button Text'
passwordPlaceholderTextCustom placeholder text for password input fieldpasswordPlaceholderText='Your Custom Password Input Placeholder Text'
errorTextCustom error state texterrorText='Your Custom Error Text'
hasErrorWhether the component has an error statehasError={true}
groupused to set the groupgroup={groupObject}
descriptionUsed to set Custom Descriptiondescription='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.