const GUID: string = "GUID";CometChat.leaveGroup(GUID).then((hasLeft: boolean) => {console.log("Group left successfully:", hasLeft);}, (error: CometChat.CometChatException) => {console.log("Group leaving failed with exception:", error);});
const GUID = "GUID";CometChat.leaveGroup(GUID).then(hasLeft => { console.log("Group left successfully:", hasLeft);}, error => { console.log("Group leaving failed with exception:", error);});
Parameter
Description
GUID
The GUID of the group you would like to leave
Once a group is left, the user will no longer receive any updates or messages pertaining to the group.On success, the method resolves with true (boolean).
CometChat.addGroupListener( "UNIQUE_LISTENER_ID", new CometChat.GroupListener({ onGroupMemberLeft: (message, leavingUser, group) => { console.log("User left", { message, leavingUser, group }); } }));
Always remove group listeners when they’re no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.