# Manage chat group members (/en/realtime-media/im/build/build-groups-rooms-and-threads/chat-group/manage-group-members/unity)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Chat groups enable real-time messaging among multiple users.

    This page shows how to use the Chat SDK to manage the members of a chat group in your app.

    ## Understand the tech [#understand-the-tech-5]

    The Chat SDK provides the `Group`, `IGroupManager`, and `IGroupManagerDelegate` classes for chat group management, which allows you to implement the following features:

    ## Prerequisites [#prerequisites-5]

    Before proceeding, ensure that you meet the following requirements:

    * You have initialized the Chat SDK. For details, see [SDK quickstart](../../../get-started-sdk).
    * You understand the call frequency limits of the Chat APIs supported by different pricing plans as described in [Limitations](../../limitations).
    * You understand the number of chat groups and chat group members supported by different pricing plans as described in [Pricing Plan Details](../../../reference/pricing-plan-details).

    ## Implementation [#implementation-5]

    This section describes how to call the APIs provided by the Chat SDK to implement chat group features.

    ### Add a user to a chat group [#add-a-user-to-a-chat-group-3]

    The logic of adding a user to a chat group varies according to the `GroupStyle` and `inviteNeedConfirm` settings when creating the chat group. For details, see [Create a Chat Group](./manage-chat-groups#create-a-chat-group).

    The following code sample shows how to call `AddGroupMembers` to add a user to a chat group:

    ```csharp
    SDKClient.Instance.GroupManager.AddGroupMembers(groupId, members, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    ### Remove a member from a chat group [#remove-a-member-from-a-chat-group-3]

    Only the chat group owner and admins can call `DeleteGroupMembers` to remove one or more members from a chat group. Once removed from the chat group, the member receives the `IGroupManagerDelegate#OnUserRemovedFromGroup` callback, while all the other members receive the `IGroupManagerDelegate#OnMembersExitedFromGroup` callback. Users can join the chat group again after being removed.

    The following code sample shows how to remove a member from a chat group:

    ```csharp
    SDKClient.Instance.GroupManager.DeleteGroupMembers(groupId, list, new CallBack (
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    ### Manage the chat group owner and admins [#manage-the-chat-group-owner-and-admins-3]

    #### Transfer the chat group ownership [#transfer-the-chat-group-ownership-3]

    Only the chat group owner can call `ChangeGroupOwner` to transfer the ownership to the specified chat group member. Once the ownership is transferred, the former chat group owner becomes a regular member, and the new owner receives the `IGroupManagerDelegate#OnOwnerChangedFromGroup` callback.

    The following code sample shows how to transfer the chat group ownership:

    ```csharp
    SDKClient.Instance.GroupManager.ChangeGroupOwner(groupId, newOwner, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Add a chat group admin [#add-a-chat-group-admin-3]

    Only the chat group owner can call `AddGroupAdmin` to add an admin. Once promoted to an admin, the new admin and the other chat group admins receive the `IGroupManagerDelegate#OnAdminAddedFromGroup` callback.

    The following code sample shows how to add a chat group admin:

    ```csharp
    SDKClient.Instance.GroupManager.AddGroupAdmin(groupId, adminId, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Remove a chat group admin [#remove-a-chat-group-admin-3]

    Only the chat group owner can call `RemoveGroupAdmin` to remove an admin. Once demoted to a regular member, the former admin and the other chat group admins receive the `IGroupManagerDelegate#OnAdminRemovedFromGroup` callback.

    The following code sample shows how to remove a chat group admin:

    ```csharp
    SDKClient.Instance.GroupManager.RemoveGroupAdmin(groupId, adminId, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    ### Manage the chat group blocklist [#manage-the-chat-group-blocklist-5]

    #### Add a member to the chat group blocklist [#add-a-member-to-the-chat-group-blocklist-3]

    Only the chat group owner and admins can call `BlockGroupMembers` to add the specified member to the chat group blocklist. Once added to the blocklist, this member receives the `IGroupManagerDelegate#OnUserRemovedFromGroup` callback, while all the other members receive the `IGroupManagerDelegate#OnMembersExitedFromGroup`. After being added to blocklist, this user cannot send or receive messages in the chat group. They can no longer join the chat group until they are removed from the blocklist.

    The following code sample shows how to add a member to the chat group blocklist:

    ```csharp
    SDKClient.Instance.GroupManager.BlockGroupMembers(groupId, members, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Remove a member from the chat group blocklist [#remove-a-member-from-the-chat-group-blocklist-3]

    Only the chat group owner and admins can call `UnBlockGroupMembers` to remove the specified member from the chat group blocklist.

    The following code sample shows how to remove a member from the chat group blocklist:

    ```csharp
    SDKClient.Instance.GroupManager.UnBlockGroupMembers(groupId, members, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Retrieve the chat group blocklist [#retrieve-the-chat-group-blocklist-3]

    Only the chat group owner and admins can call `GetGroupBlockListFromServer` to retrieve the chat group blocklist.

    The following code sample shows how to retrieve the chat group blocklist:

    ```csharp
    SDKClient.Instance.GroupManager.GetGroupBlockListFromServer(groupId, pageNum, pageSize, callback: new ValueCallBack>(
      onSuccess: (list) =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    ### Manage the chat group mute list [#manage-the-chat-group-mute-list-5]

    #### Add a member to the chat group mute list [#add-a-member-to-the-chat-group-mute-list-3]

    Only the chat group owner and admins can call `MuteGroupMembers` to add the specified member to the chat group mute list. Once added to the mute list, this member and all the other chat group admins or owner receive the `IGroupManagerDelegate#OnMuteListAddedFromGroup` callback. Once a chat group member is added to the chat group mute list, they can no longer send chat group messages, not even after being added to the chat group allow list.

    The following code sample shows how to add a member to the chat group mute list:

    ```csharp
    // muteMilliseconds: The mute duration. If you pass `-1`, members are muted permanently.
    SDKClient.Instance.GroupManager.MuteGroupMembers(groupId, members, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Remove a member from the chat group mute list [#remove-a-member-from-the-chat-group-mute-list-3]

    Only the chat group owner and admins can call `UnMuteGroupMembers` to remove the specified member from the chat group mute list. Once removed from the chat group mute list, this member and all the other chat group admins or owner receive the `IGroupManagerDelegate#OnMuteListRemovedFromGroup` callback.

    The following code sample shows how to remove a member from the chat group mute list:

    ```csharp
    SDKClient.Instance.GroupManager.UnMuteGroupMembers(groupId, members, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Retrieve the chat group mute list [#retrieve-the-chat-group-mute-list-3]

    Only the chat group owner and admins can call `GetGroupMuteListFromServer` to retrieve the chat group mute list from the server.

    The following code sample shows how to retrieve the chat group mute dictionary:

    ```csharp
    SDKClient.Instance.GroupManager.GetGroupMuteListFromServer(groupId, callback: new ValueCallBack>(
      onSuccess: (list) => {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    ### Mute and unmute all the chat group members [#mute-and-unmute-all-the-chat-group-members-4]

    #### Mute all the chat group members [#mute-all-the-chat-group-members-3]

    Only the chat group owner and admins can call `MuteGroupAllMembers` to mute all the chat group members. All members in the group can receive the `IGroupManagerDelegate#OnAllMemberMuteChangedFromGroup` event and only those in the chat group allow list can send messages in the chat group.

    Unlike muting a chat group member, this kind of mute does not expire automatically after a certain period and you need to call the `UnMuteGroupAllMembers` method to unmute all members in the chat group.

    The following sample code shows how to mute all the chat group members:

    ```csharp
    SDKClient.Instance.GroupManager.MuteGroupAllMembers(groupId, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Unmute all the chat group members [#unmute-all-the-chat-group-members-3]

    Only the chat group owner and admins can call `UnMuteGroupAllMembers` to unmute all the chat group members. All members in the group can receive the `IGroupManagerDelegate#OnAllMemberMuteChangedFromGroup` event

    The following sample code shows how to unmute all the chat group members:

    ```csharp
    SDKClient.Instance.GroupManager.UnMuteGroupAllMembers(groupId, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    ### Manage the chat group allow list [#manage-the-chat-group-allow-list-5]

    The chat group owner and admins are added to the chat group allow list by default.

    #### Add a member to the chat group allow list [#add-a-member-to-the-chat-group-allow-list-3]

    Only the chat group owner and admins can call `AddGroupWhiteList` to add the specified member to the chat group allow list. Members in the chat group allow list can send chat group messages even when the chat group owner or admin has muted all chat group members. However, if a member is already in the chat group mute list, this member still cannot send messages in the group even after being added to the group allow list.

    The following code sample shows how to add a member to the chat group allow list:

    ```csharp
    SDKClient.Instance.GroupManager.AddGroupWhiteList(groupId, members, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Remove a member from the chat group allow list [#remove-a-member-from-the-chat-group-allow-list-3]

    Only the chat group owner and admins can call `RemoveGroupWhiteList` to remove the specified member from the chat group allow list.

    The following code sample shows how to remove a member from the chat group allow list:

    ```csharp
    SDKClient.Instance.GroupManager.RemoveGroupWhiteList(groupId, members, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Check whether a user is added to the allow list [#check-whether-a-user-is-added-to-the-allow-list-3]

    All chat group members can call `checkIfInGroupWhiteList` to check whether they are added to the chat group allow list.

    The following code sample shows how to check whether a user is on the chat group allow list:

    ```csharp
    public void checkIfInGroupWhiteList(final String groupId, EMValueCallBack callBack)
    SDKClient.Instance.GroupManager.CheckIfInGroupWhiteList(groupId, new ValueCallBack(
      onSuccess: (ret) => {
      },
      onError: (code, desc)=> {
      }
    ));
    ```

    #### Retrieve the chat group allow list [#retrieve-the-chat-group-allow-list-3]

    Only the chat group owner and admins can call `GetGroupWhiteListFromServer` to retrieve the chat group allow list.

    The following code sample shows how to retrieve the chat group allow list:

    ```csharp
    SDKClient.Instance.GroupManager.GetGroupWhiteListFromServer(currentGroupId, callback: new ValueCallBack>(
      onSuccess: (list) => {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    ### Listen for chat group events [#listen-for-chat-group-events-5]

    For details, see [Chat Group Events](./manage-chat-groups#listen-for-chat-group-events).

    
  
      
  
