CometChat Pro Documentation

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

Get List of Groups

In order to fetch the list of groups, you can use the GroupsRequest class. To use this class i.e to create an object of the GroupsRequest class, you need to use the GroupsRequestBuilder class. The GroupsRequestBuilder class allows you to set the parameters based on which the groups are to be fetched.

The GroupsRequestBuilder class allows you to set the below parameters:

  1. setLimit(int limit) - This method sets the limit i.e. the number of groups that should be fetched in a single iteration.
GroupsRequest groupsRequest = new GroupsRequest.GroupsRequestBuilder().setLimit(limit).build();
  1. setSearchKeyWord(String searchString) - This method allows you to set the search string based on which the groups are to be fetched.
GroupsRequest groupsRequest = new GroupsRequest.GroupsRequestBuilder().setSearchKeyWord("abc").build();

Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the GroupsRequest class.

Once you have the object of the GroupsRequest class, you need to call the fetchNext() method. Calling this method will return a list of Group objects containing n number of groups where n is the limit set in the builder class.

private GroupsRequest groupsRequest = null;
private int limit = 30;

groupsRequest = new GroupsRequest.GroupsRequestBuilder().setLimit(limit).build();

groupsRequest.fetchNext(new CometChat.CallbackListener<List<Group>>() {
  @Override
  public void onSuccess(List <Group> list) {
    Log.d(TAG, "Groups list fetched successfully: " + list.size());
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Groups list fetching failed with exception: " + e.getMessage());
  }
});
var groupRequest:GroupsRequest?=null
val limit:Int=30

groupRequest=GroupsRequest.GroupsRequestBuilder().setLimit(limit).build()

  groupRequest?.fetchNext(object :CometChat.CallbackListener<List<Group>>(){
    override fun onSuccess(p0: List<Group>?) {
      Log.d(TAG, "Groups list fetched successfully: " + p0?.size)
    }
    override fun onError(p0: CometChatException?) {
      Log.d(TAG, "Groups list fetching failed with exception: " + p0?.message)
    }
  })

Get Group information

To get the information of a group, you can use the getGroup() method.

private String GUID = "GUID";

 CometChat.getGroup(GUID, new CometChat.CallbackListener<Group>() {
    @Override
    public void onSuccess(Group group) {
    Log.d(TAG, "Group details fetched successfully: " + group.toString());        
    }

    @Override
    public void onError(CometChatException e) { 
     Log.d(TAG, "Group details fetching failed with exception: " + e.getMessage());   
  
 }
     });
val GUID:String="GUID"

CometChat.getGroup(GUID,object :CometChat.CallbackListener<Group>(){
  override fun onSuccess(p0: Group?) {
    Log.d(TAG, "Group details fetched successfully: " + p0?.toString())
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group details fetching failed with exception: " +p0?.message)
  }
})
Parameter
Description

GUID

The GUID of the group for whom the details are to be fetched

On success, the Group object containing the details of the group is returned.

Create a Group

You can create a group using createGroup() method. This method takes a Group object as input.

To create an object of Group class, you can use either of the below two constructors:

  1. new Group(String GUID, String name, String groupType, String password)
  2. new Group(String GUID, String name, String groupType, String password, String icon, String description)

The groupType needs to be either of the below 3 values:

1.CometChatConstants.GROUP_TYPE_PUBLIC (public)
2.CometChatConstants.GROUP_TYPE_PASSWORD (password)
3.CometChatConstants.GROUP_TYPE_PRIVATE (private)

private String GUID = "GUID";
private String groupName = "Hello Group!";
private String groupType = CometChatConstants.GROUP_TYPE_PUBLIC;
private String password = "";

Group group = new Group(GUID, groupName, groupType, password);

CometChat.createGroup(group, new CometChat.CallbackListener<Group>(){
  @Override
  public void onSuccess(Group group) {
    Log.d(TAG, "Group created successfully: " + group.toString());
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Group creation failed with exception: " + e.getMessage());
  }
});
val GUID:String="GUID"
val groupName:String="Hello Group"
val groupType:String=CometChatConstants.GROUP_TYPE_PUBLIC
val password:String=""

val group=Group(GUID,groupName,groupType,password)

CometChat.createGroup(group,object :CometChat.CallbackListener<Group>(){
  override fun onSuccess(p0: Group?) {
    Log.d(TAG, "Group created successfully: " + p0?.toString())
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group creation failed with exception: " + p0?.message)
  }
})

The createGroup() method takes the following parameters:

Parameter
Description

group

An instance of Group class

After successful creation of the group, you will receive an instance of Group class which contains all the information about the particular group.

Join a Group

In order to start participating in group conversations, you will have to join a group. You can do so using the joinGroup() method.

private String GUID = "GUID";
private String groupType = CometChatConstants.GROUP_TYPE_PUBLIC;
private String password = "";

CometChat.joinGroup(GUID, groupType, password, new CometChat.CallbackListener<Group>() {
  @Override
  public void onSuccess(Group joinedGroup) {
    Log.d(TAG, joinedGroup.toString());
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Group joining failed with exception: " + e.getMessage());
  }
});
val GUID:String="GUID"
val groupType:String=CometChatConstants.GROUP_TYPE_PUBLIC
val password:String=""


CometChat.joinGroup(GUID,groupType,password,object:CometChat.CallbackListener<Group>(){
  override fun onSuccess(p0: Group?) {
    Log.d(TAG, p0.toString());
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group joining failed with exception: " + p0?.message)
  }
})

The joinGroup() method takes the below parameters

Parameter
Description

GUID

The GUID of the group you would like to join

groupType

Type of the group. CometChat provides 3 types of groups viz. 1.CometChatConstants.GROUP_TYPE_PUBLIC (public)
2.CometChatConstants.GROUP_TYPE_PASSWORD (password)
3.CometChatConstants.GROUP_TYPE_PRIVATE (private)

password

Password is mandatory in case of a password protected group.

Once you have joined a group successfully, you can send and receive messages in that group.

CometChat keeps a track of the groups joined and you do not need to join the group everytime you want to communicate in the group.

You can identify if a group is joined using the hasJoined parameter in the Group object.

Add Members to Group

You can add members to the group using the addMembersToGroup() method. This method takes the below parameters:

  1. GUID - GUID of the group the members are to be added to.
  2. List<GroupMember> members - This is a list of GroupMember objects. In order to add members, you need to create an object of the GroupMember class. The UID and the scope of the GroupMember are mandatory.
  3. List<String> bannedMembers - This is the list of UIDs that need to be banned from the Group. This can be set to null if there are no members to be banned.
  4. Callback.
List<GroupMember> members = new ArrayList<>();
members.add(new GroupMember("uid1",CometChatConstants.SCOPE_MODERATOR));
members.add(new GroupMember("uid2", CometChatConstants.SCOPE_ADMIN));

CometChat.addMembersToGroup("GUID", members, null, new CometChat.CallbackListener<HashMap<String, String>>(){
  @Override
    public void onSuccess(HashMap<String, String> successMap) {
    	Log.d("CometChatActivity", success);
  }

  @Override
    public void onError(CometChatException e) {
    	Toast.makeText(CometChatActivity.this,
                     e.getMessage(),Toast.LENGTH_LONG).show();
  }
});

In the onSuccess() method of the CallbackListener, you will receive a HashMap which will contain the UID of the users and the value will either be success or an error message describing why the operation to add the user to the group or ban the user failed.

To receive Real-Time Events for the same, you need to implement the onAddedToGroup() and onMemberAddedToGroup() methods of the GroupListener class.

  • onAddedToGroup() - This method is triggered when the LoggedIn User is added to the Group.
  • onMemberAddedToGroup() - This method is triggered when other users are added to the group so that the logged in user is informed of the other members added to the group.
 CometChat.addGroupListener("LISTENER_ID", new CometChat.GroupListener() {
   @Override
     public void onMemberAddedToGroup(Action action, User addedby, User userAdded, Group addedTo) {
     Log.d("onMemberAddedToGroup", action.getMessage());
   }

   @Override
     public void onAddedToGroup(Action action, User addedby, User userAdded, Group addedTo) {
     	Log.d("onAddedToGroup", action.getMessage());
   }
 });

Leave a Group

In order to stop receiving updates and messages for any particular joined group, you will have to leave the group using the leaveGroup() method.

private String GUID = "GUID";

CometChat.leaveGroup(GUID, new CometChat.CallbackListener<String>() {
   @Override
   public void onSuccess(String successMessage) {
      Log.d(TAG, successMessage);        
    }

   @Override
   public void onError(CometChatException e) {
      Log.d(TAG, "Group leaving failed with exception: " + e.getMessage());
    }
  });
val GUID:String="GUID"

CometChat.leaveGroup(GUID,object :CometChat.CallbackListener<String>(){
  override fun onSuccess(p0: String?) {
    Log.d(TAG, "Group left successfully")
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group leaving failed with exception: " + p0?.message)
  }

})
Parameter
Description

GUID

The UID 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.

Get the List of Group Members

In order to fetch the list of groups members for a group, you can use the GroupMembersRequest class. To use this class i.e to create an object of the GroupMembersRequest class, you need to use the GroupMembersRequestBuilder class. The GroupMembersRequestBuilder class allows you to set the parameters based on which the groups are to be fetched.

The GroupMembersRequestBuilder class allows you to set the below parameters:

The GUID of the group for which the members are to be fetched must be specified in the constructor of the GroupMembersRequestBuilder class.

  1. setLimit(int limit) - This method sets the limit i.e. the number of members that should be fetched in a single iteration.
GroupMembersRequest groupMembersRequest = new GroupMembersRequest.GroupMembersRequestBuilder(GUID)
.setSearchKeyword("abc").build();
  1. setSearchKeyword(String searchString) - This method allows you to set the search string based on which the group members are to be fetched.
GroupMembersRequest groupMembersRequest = new GroupMembersRequest.GroupMembersRequestBuilder(GUID)
.setLimit(limit).build();

Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the GroupMembersRequest class.

Once you have the object of the GroupMembersRequest class, you need to call the fetchNext() method. Calling this method will return a list of GroupMember objects containing n number of members where n is the limit set in the builder class.

private GroupMembersRequest groupMembersRequest = null;
private String GUID = "GUID";
private int limit = 30;

groupMembersRequest = new GroupMembersRequest.GroupMembersRequestBuilder(GUID).setLimit(limit).build();

groupMembersRequest.fetchNext(new CometChat.CallbackListener<List<GroupMember>>(){
     @Override
     public void onSuccess(List<GroupMember> list) {
        Log.d(TAG, "Group Member list fetched successfully: " + list.size());
      }
     @Override
     public void onError(CometChatException e) {
      Log.d(TAG, "Group Member list fetching failed with exception: " + e.getMessage());
     }
            
 });
var groupMembersRequest:GroupMembersRequest?=null
val GUID:String="GUID"
val limit:Int=30

groupMembersRequest=GroupMembersRequest.GroupMembersRequestBuilder(GUID).setLimit(limit).build()

groupMembersRequest?.fetchNext(object:CometChat.CallbackListener<List<GroupMember>>(){
  override fun onSuccess(p0: List<GroupMember>?){
    Log.d(TAG, "Group Member list fetched successfully: " + p0?.size)
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group Member list fetching failed with exception: " + p0?.message)
  }
})

Update Group

You can update the existing details of the group using the updateGroup() method.

private String GUID = "GUID";
private String groupName = "Hello Group!";
private String groupType = CometChatConstants.GROUP_TYPE_PUBLIC;
private String password = "";
Group group = new Group(GUID, groupName, groupType, password);

CometChat.updateGroup(group,  new CometChat.CallbackListener<Group>() {
  @Override
  public void onSuccess(Group group) {
    Log.d(TAG, "Groups details updated successfully: " + group.toString());
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Group details update failed with exception: " + e.getMessage());
  }
});
val GUID:String="GUID"
val groupName:String="Hello Group!"
val groupType:String = CometChatConstants.GROUP_TYPE_PUBLIC
val password:String=""

val group=Group(GUID,groupName,groupType,password)

   CometChat.updateGroup(group,object :CometChat.CallbackListener<Group>(){
     override fun onSuccess(p0: Group?) {
       Log.d(TAG, "Groups details updated successfully: " + p0?.toString())
     }
     override fun onError(p0: CometChatException?) {
       Log.d(TAG, "Group details update failed with exception: " + p0?.message)
     }
   })

This method takes an instance of the Group class as a parameter which should contain the data that you wish to update.

Parameter
Description

group

an instance of class Group

After a successful update of the group, you will receive an instance of Group class containing update information of the group.

Delete Group

To delete a group you need to use the deleteGroup() method. The user must be an Admin of the group they are trying to delete.

private String GUID = "GUID";

CometChat.deleteGroup(GUID, new CometChat.CallbackListener<String>() {
  @Override
  public void onSuccess(String successMessage) {
    Log.d(TAG, "Groups deleted successfully: ");
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Group delete failed with exception: " + e.getMessage());
  }
});
val GUID:String="GUID"

CometChat.deleteGroup(GUID,object :CometChat.CallbackListener<String>(){
  override fun onSuccess(p0: String?) {
    Log.d(TAG, "Groups deleted successfully: ")
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group delete failed with exception: " +p0?.message)
  }
})

The deleteGroup() method takes the following parameters:

Parameter
Description

GUID

The GUID of the group you would like to delete

Group Actions

There are certain actions that can be performed on the group members:

  1. Kick a member from the group
  2. Ban a member from the group
  3. Unban a member from the group
  4. Update the scope of the member of the group

Please note: All the above-mentioned actions can only be performed by the Admin or the Moderator of the group.

Kick a Group Member

The Admin or Moderator of a group can kick a member out of the group using the kickGroupMember() method.

private String UID = "UID";
private String GUID = "GUID";

CometChat.kickGroupMember(UID, GUID, new CometChat.CallbackListener<String>() {
  @Override
  public void onSuccess(String successMessage) {
    Log.d(TAG, "Group member kicked successfully");
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Group member kicking failed with exception: " + e.getMessage());
  }
});
val GUID:String="GUID"
val UID:String="UID"

CometChat.kickGroupMember(UID,GUID,object :CometChat.CallbackListener<String>(){
  override fun onSuccess(p0: String?) {
    Log.d(TAG, "Group member kicked successfully")
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group member kicking failed with exception: " + p0?.message)
  }
})

The kickGroupMember() takes following parameters

Parameter
Description

UID

The UID of the user to be kicked

GUID

The GUID of the group from which user is to be kicked

The kicked user will be no longer part of the group and can not perform any actions in the group, but the kicked user can rejoin the group.

Ban a Group Member

The Admin or Moderator of the group can ban a member from the group using the banGroupMember() method.

private String UID = "UID";
private String GUID = "GUID";

CometChat.banGroupMember(UID, GUID, new CometChat.CallbackListener<String>() {
  @Override
  public void onSuccess(String successMessage) {
    Log.d(TAG, "Group member banned successfully");
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Group member banning failed with exception: " + e.getMessage());
  }
});
val GUID:String="GUID"
val UID:String="UID"

CometChat.banGroupMember(UID,GUID,object:CometChat.CallbackListener<String>(){
  override fun onSuccess(p0: String?) {
    Log.d(TAG, "Group member banned successfully")
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group member banning failed with exception: " + p0?.message)
  }
})

The banGroupMember() method takes the following parameters:

Parameter
Description

UID

The UID of the user to be banned

GUID

The GUID of the group from which user is to be banned

The banned user will be no longer part of the group and can not perform any actions in the group. A banned user cannot rejoin the group same group without being unbanned.

Unban a Banned Group Member from a Group

Only Admin or Moderators of the group can unban a previously banned member from the group using the unbanGroupMember() method.

private String UID = "UID";
private String GUID = "GUID";

CometChat.unbanGroupMember(UID, GUID, new CometChat.CallbackListener<String>() {
  @Override
  public void onSuccess(String successMessage) {
    Log.d(TAG, "Group Member unbanned successfully");
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Group Member unbanning failed with exception: " + e.getMessage());
  }
});
val GUID:String="GUID"
val UID:String="UID"

CometChat.unbanGroupMember(UID,GUID,object :CometChat.CallbackListener<String>(){
  override fun onSuccess(p0: String?) {
    Log.d(TAG, "Group Member unbanned successfully")
  }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "Group Member unbanning failed with exception: " + p0?.message)
  }
})

The unbanGroupMember() method takes the following parameters

Parameter
Description

UID

The UID of the user to be unbanned

GUID

The UID of the group from which user is to be banned

The unbanned user can now rejoin the group.

Get List of Banned Members for a Group

In order to fetch the list of banned groups members for a group, you can use the BannedGroupMembersRequest class. To use this class i.e to create an object of the BannedGroupMembersRequest class, you need to use the BannedGroupMembersRequestBuilder class. The BannedGroupMembersRequestBuilder class allows you to set the parameters based on which the banned group members are to be fetched.

The BannedGroupMembersRequestBuilder class allows you to set the below parameters:

The GUID of the group for which the banned members are to be fetched must be specified in the constructor of the GroupMembersRequestBuilder class.

  1. setLimit(int limit) - This method sets the limit i.e. the number of banned members that should be fetched in a single iteration.
BannedGroupMembersRequest bannedGroupMembersRequest = new BannedGroupMembersRequest.BannedGroupMembersRequestBuilder(GUID)
.setLimit(limit)
.build();
  1. setSearchKeyword(String searchString) - This method allows you to set the search string based on which the banned group members are to be fetched.
BannedGroupMembersRequest bannedGroupMembersRequest = new BannedGroupMembersRequest.BannedGroupMembersRequestBuilder(GUID)
.setSearchKeyword("abc")
.build();

Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the BannedGroupMembersRequest class.

Once you have the object of the BannedGroupMembersRequest class, you need to call the fetchNext() method. Calling this method will return a list of GroupMember objects containing n number of banned members where n is the limit set in the builder class.

private BannedGroupMembersRequest bannedGroupMembersRequest = null;
private String GUID = "GUID";
private int limit = 30;

bannedGroupMembersRequest = new BannedGroupMembersRequest.BannedGroupMembersRequestBuilder(GUID).setLimit(limit).build();

bannedGroupMembersRequest.fetchNext(new CometChat.CallbackListener<List<GroupMember>>(){
  @Override
  public void onSuccess(List <GroupMember> list) {
    Log.d(TAG, "Banned Group Member list fetched successfully: " + list.size());
  }
  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Banned Group Member list fetching failed with exception: " + e.getMessage());
  }
});
var bannedGroupMembersRequest:BannedGroupMembersRequest?=null
val GUID:String="GUID"
val limit:Int=30

bannedGroupMembersRequest=BannedGroupMembersRequest.BannedGroupMembersRequestBuilder(GUID).setLimit(limit).build()

bannedGroupMembersRequest?.fetchNext(object :CometChat.CallbackListener<List<GroupMember>>(){
  override fun onSuccess(p0: List<GroupMember>?) {
     Log.d(TAG, "Banned Group Member list fetched successfully: " + p0?.size)
     }
 override fun onError(p0: CometChatException?) {
     Log.d(TAG, "Banned Group Member list fetching failed with exception: " + p0?.message)
     }
})

Change Scope of a Group Member

In order to change the scope of a group member, you can use the changeGroupMemberScope().

private String GUID = "GUID";
private String UID = "UID";
private String scope = CometChatConstants.SCOPE_ADMIN;

 CometChat.updateGroupMemberScope(UID, GUID, scope, new      
 CometChat.CallbackListener<String>() {
   @Override
    public void onSuccess(String successMessage) {
     Log.d(TAG, "User scope updated successfully");
    }

    @Override
    public void onError(CometChatException e) {
     Log.d(TAG, "User scope update failed with exception: " + e.getMessage());
     }
   });
val GUID:String="GUID"
val UID:String="UID"
val scope:String = CometChatConstants.SCOPE_ADMIN

CometChat.updateGroupMemberScope(UID,GUID,scope,object:CometChat.CallbackListener<String>(){
   override fun onSuccess(p0: String?) {
     Log.d(TAG, "User scope updated successfully")
   }
  override fun onError(p0: CometChatException?) {
    Log.d(TAG, "User scope update failed with exception: " + p0?.message)
  }
})

This method takes the below parameters:

Parameter
Description

UID

The UID of the member whose scope you would like to change

GUID

The GUID of the group for which the member's scope needs to be changed

scope

the updated scope of the member. This can be either of the 3 values:
1.CometChatConstants.SCOPE_ADMIN (admin)
2.CometChatConstants.SCOPE_MODERATOR (moderator)
3.CometChatConstants.SCOPE_PARTICIPANT (participant)

The default scope of any member is participant. Only the admin of the group can change the scope of any participant in the group.

Receive Group Events

For every activity you wish to receive the group events in, you need to register the GroupEventListener listener using the addGroupEventListener() method.

 String listenerID = "UNIQUE_LISTENER_ID";

 CometChat.addGroupListener(listenerID, new CometChat.GroupListener() {
     @Override
     public void onGroupMemberJoined(Action action, User joinedUser, Group joinedGroup) {
     Log.d(TAG, joinedUser.getName() + " joined " + joinedGroup.getName());
     }

     @Override
     public void onGroupMemberLeft(Action action, User leftUser, Group joinedGroup) {
     Log.d(TAG, joinedUser.getName() + " left " + joinedGroup.getName());
     }

     @Override
     public void onGroupMemberKicked(Action action, User kickedUser, User kickedBy, Group kickedFrom) {
     Log.d(TAG, kickedUser.getName() + " kicked by " + kickedBy.getName());
     }

     @Override
     public void onGroupMemberBanned(Action action, User bannedUser, User bannedBy, Group bannedFrom) {
      Log.d(TAG, bannedUser.getName() + " banned by " + bannedBy.getName());
     }

     @Override
      public void onGroupMemberUnbanned(Action action, User unbannedUser, User unbannedBy, Group unbannedFrom) {
       Log.d(TAG, unbannedUser.getName() + " unbanned by " + unbannedBy.getName());
      }

      @Override
      public void onGroupMemberScopeChanged(Action action, User user, String scopeChangedTo, String scopeChangedFrom, Group group) {
        Log.d(TAG," Scope for user "+user.getName()+" changed from "+scopeChangedFrom+ " to "+scopeChangedTo);
      }
  });
val listenerID:String = "UNIQUE_LISTENER_ID"

CometChat.addGroupListener(listenerID,object:CometChat.GroupListener(){
      override fun onGroupMemberKicked(action: Action?, kickedUser: User?, kickedBy: User?, kickedFrom: Group?) {
      Log.d(TAG, kickedUser?.name + " kicked by " + kickedBy?.name)
      }
      override fun onGroupMemberScopeChanged(action: Action?, user: User?, scopeChangedTo: String?, scopeChangedFrom: String?, group: Group?) {
      Log.d(TAG," Scope for user "+user?.name+" changed from "+scopeChangedFrom+ " to "+scopeChangedTo)
      }
      override fun onGroupMemberUnbanned(action: Action?, unbannedUser: User?, unbannedBy: User?, unbannedFrom: Group?) {
      Log.d(TAG, unbannedUser?.name + " unbanned by " + unbannedBy?.name)
      }
      override fun onGroupMemberBanned(action: Action?, bannedUser: User?, bannedBy: User?, bannedFrom: Group?) {
      Log.d(TAG, bannedUser?.name + " banned by " + bannedBy?.name)
      }
      override fun onGroupMemberLeft(action: Action?, joinedUser: User?, joinedGroup: Group?) {
      Log.d(TAG, joinedUser?.name + " left " + joinedGroup?.name)
      }
      override fun onGroupMemberJoined(action: Action?, joinedUser: User?, joinedGroup: Group?) {
      Log.d(TAG, joinedUser?.name + " joined " + joinedGroup?.name)
      }
 })

This method takes the below parameters:

Parameter
Description

listenerID

An ID that uniquely identifies that listener. We recommend using the activity or fragment name.

We recommend you remove the listener once the activity or fragment is not in use.

private String listenerID = "UNIQUE_LISTENER_ID";

CometChat.removeGroupListener(listenerID);
val listenerID:String = "UNIQUE_LISTENER_ID"

CometChat.removeMessageListener(listenerID)

Groups


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.