- Kick a member from the group
- Ban a member from the group
- Unban a member from the group
- Update the scope of the member of the group
Kick a Group Member
The Admin or Moderator of the group can kick a member out of the group using thekickUser()
method provided by the CometChat class. This method can be used as shown below:
kickGroupMember()
takes the 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 |
Ban a Group Member
The Admin or Moderator of the group can ban a member from the group using thebanGroupMember()
method.
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 |
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 theunbanGroupMember()
method.
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. |
Get List of Banned Members for a Group
In order to fetch the list of banned groups members for a group, you can use theBannedGroupMembersRequest
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 BannedGroupMembersRequestBuilder
class.
set(limit: Int)
- This method sets the limit i.e. the number of banned members that should be fetched in a single iteration.
set(searchKeyword : String)
- This method allows you to set the search string based on which the banned group members are to be fetched.
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.
Real-Time Group Member Kicked/Banned Events
In order to receive user Events for kick/ban/unban you must add protocol conformanceCometChatGroupDelegate
as shown for following methods:
onGroupMemberKicked()
- triggered when any group member has been kicked.onGroupMemberBanned()
- triggered when any group member has been banned.onGroupMemberUnbanned()
- triggered when any group member has been unbanned. methods of theCometChatGroupDelegate
.
Missed Group Member Kicked/Banned Events
In other words, as a member of a group, how do I know when someone is banned/kicked when my app is not running? When you retrieve the list of previous messages if a member has been kicked/banned/unbanned from any group that the logged-in user is a member of, the list of messages will contain anAction
message. An Action
message is a sub-class of BaseMessage
class.
For group member kicked event, the details can be obtained using the below fields of the Action
class-
action
-kicked
actionBy
- User object containing the details of the user who has kicked the memberactionOn
- User object containing the details of the member that has been kickedactionFor
- Group object containing the details of the Group from which the member was kicked
Action
class-
action
-banned
actionBy
- User object containing the details of the user who has banned the memberactionOn
- User object containing the details of the member that has been bannedactionFor
- Group object containing the details of the Group from which the member was banned
Action
class-
action
-unbanned
actionBy
- User object containing the details of the user who has unbanned the memberactionOn
- User object containing the details of the member that has been unbannedactionFor
- Group object containing the details of the Group from which the member was unbanned