Created
October 18, 2021 14:21
-
-
Save hieptl/d9d8d2c97e9a8cb87064d015549ff129 to your computer and use it in GitHub Desktop.
CreateGroup.tsx - Create Group CometChat - Ionic Chat App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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