Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created October 18, 2021 14:21
Show Gist options
  • Save hieptl/d9d8d2c97e9a8cb87064d015549ff129 to your computer and use it in GitHub Desktop.
Save hieptl/d9d8d2c97e9a8cb87064d015549ff129 to your computer and use it in GitHub Desktop.
CreateGroup.tsx - Create Group CometChat - Ionic Chat App
...
const createGroup = () => {
const groupName = groupNameRef.current.value;
if (isGroupValid(groupName)) {
setIsLoading(true);
const GUID = uuidv4();
const groupType = cometChat.GROUP_TYPE.PUBLIC;
const groupIcon = generateAvatar();
const password = "";
const group = new cometChat.Group(GUID, groupName, groupType, password);
group.setIcon(groupIcon);
cometChat.createGroup(group).then(
(group: any) => {
setIsLoading(false);
alert(`${groupName} was created successfully`)
},
(error: any) => {
setIsLoading(false);
alert('Cannot create your group. Please try again later')
}
);
}
};
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment