Skip to main content
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

On Success — A Group object containing all details of the joined group:Group Object:
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.
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.

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