Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created October 10, 2021 16:55
Show Gist options
  • Save hieptl/d325c63d11febdf5da684c22fa1bfee8 to your computer and use it in GitHub Desktop.
Save hieptl/d325c63d11febdf5da684c22fa1bfee8 to your computer and use it in GitHub Desktop.
CreateGroup.js - Create Group - React Native Gifted Chat App
...
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