Created
October 10, 2021 16:55
-
-
Save hieptl/d325c63d11febdf5da684c22fa1bfee8 to your computer and use it in GitHub Desktop.
CreateGroup.js - Create Group - React Native Gifted 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 = () => { | |
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 => { | |
setIsLoading(false); | |
showMessage('Info', `${groupName} was created successfully`); | |
}, | |
error => { | |
setIsLoading(false); | |
showMessage('Error', '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