Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

// Join a public group
CometChat.joinGroup("GROUP_GUID", CometChatGroupType.public,
  onSuccess: (Group group) => debugPrint("Joined: ${group.name}"),
  onError: (CometChatException e) => debugPrint("Error: ${e.message}"),
);

// Join a password-protected group
CometChat.joinGroup("GROUP_GUID", CometChatGroupType.password,
  password: "group_password",
  onSuccess: (Group group) => debugPrint("Joined: ${group.name}"),
  onError: (CometChatException e) => debugPrint("Error: ${e.message}"),
);
Group types: CometChatGroupType.public | CometChatGroupType.password | CometChatGroupType.private
Join a group to start sending and receiving messages in it. Public groups can be joined freely, password groups require the correct password, and private groups require an admin to add you (no direct join).

Join a Group

Use joinGroup() to join a group.
Available via: SDK | REST API | UI Kits

Parameters

ParameterTypeDescription
guidStringThe GUID of the group to join
groupTypeStringCometChatGroupType.public, CometChatGroupType.password, or CometChatGroupType.private
passwordStringRequired for password-protected groups (defaults to empty string)
onSuccessFunction(Group group)?Callback triggered on successful join
onErrorFunction(CometChatException excep)?Callback triggered on error
String GUID = "GUID";
String groupType = CometChatGroupType.public;
String password = "";

CometChat.joinGroup(GUID, groupType, password: password,
                  onSuccess: (Group group) {
                    debugPrint("Group Joined Successfully : $group ");
                  }, onError: (CometChatException e) {
                    debugPrint("Group Joining failed with exception: ${e.message}");
  });
On Success — A Group object containing all details of the joined group:Group Object:
ParameterTypeDescriptionSample Value
guidstringUnique identifier for the group"cometchat-guid-1"
namestringDisplay name of the group"Hello Group!"
iconstringURL of the group iconnull
descriptionstringDescription of the groupnull
membersCountnumberNumber of members in the group5
metadataobjectCustom metadata attached to the group{}
joinedAtnumberEpoch timestamp when the logged-in user joined the group1745554729
hasJoinedbooleanWhether the logged-in user has joined the grouptrue
createdAtnumberEpoch timestamp when the group was created1745551200
ownerstringUID of the group owner"cometchat-uid-1"
updatedAtnumberEpoch timestamp when the group was last updated1745554729
tagsarrayList of tags associated with the group[]
typestringType of the group (public, private, password)"public"
scopestringScope of the logged-in user in the group"participant"
passwordstringPassword for password-protected groupsnull
isBannedFromGroupbooleanWhether the logged-in user is banned from the groupfalse
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_GUID_NOT_FOUND"
messagestringHuman-readable error message"The specified group does not exist."
detailsstringAdditional technical details"Please provide a valid GUID for the group."
Once joined, you can send and receive messages in the group. CometChat tracks joined groups — you don’t need to rejoin each session. Check hasJoined on the Group object to verify membership.

Real-time Group Member Joined Events

In other words, as a member of a group, how do I know if someone joins the group when my app is running? If a user joins any group, the members of the group receive a real-time event in the onGroupMemberJoined() method of the GroupListener class.
class ClassName with GroupListener {
  // CometChat.addGroupListener("group_Listener_id", this);

  @override
  void onGroupMemberJoined(Action action, User joinedUser, Group joinedGroup) {
    debugPrint("onGroupMemberJoined");
  }
}
Always remove group listeners when they’re no longer needed (e.g., in dispose()). Failing to remove listeners can cause memory leaks and duplicate event handling.
CometChat.removeGroupListener("group_Listener_id");

Missed Group Member Joined Events

In other words, as a member of a group, how do I know if someone joins the group when my app is not running? When you retrieve the list of previous messages if a member has joined any group that the logged-in user is a member of, the list of messages will contain an Action message. An Action message is a sub-class of BaseMessage class. For the group member joined event, in the Action object received, the following fields can help you get the relevant information-
  1. action - joined
  2. actionBy - User object containing the details of the user who joined the group
  3. actionFor- Group object containing the details of the group the user has joined

Next Steps

Leave a Group

Allow members to leave a group

Retrieve Group Members

Fetch the list of members in a group

Send Messages

Send messages to group conversations

Add Members

Programmatically add members to a group