tencent cloud

Feedback

Android, iOS, Windows, and macOS

Last updated: 2024-04-01 16:22:12

    Feature Description

    For permission groups, users can define permissions for groups as needed and configure different permissions and members for different permission groups, so that users can manage groups by permissions. Community groups can be managed by permission groups. Management of permission groups is more flexible than that of admins with fixed roles, making it suitable for communities with many members and topics.
    Note:
    The permission group feature is supported for version 7.8 and later.
    To use this feature, you need to purchase the Premium edition, log in to the console, choose > Feature Configuration > Group Configuration > Group Feature Configuration > Community, and enable the community feature.
    
    The permission group V2TIMPermissionGroupInfo includes three elements: community permissions groupPermission, topic permissions topicPermission, and the group members who have these permissions. As shown in the figure above, users can configure different community permissions groupPermission and topic permissions topicPermission for different permission groups, and add different group members to achieve differentiated permission management. In addition, users can set default permissions defaultPermissions for communities and topics in community information V2TIMGroupInfo and topic information V2TIMTopicInfo. In this case, all group members have these default permissions. The rules for permission group management are as follows:
    To enable the permission group feature, set enablePermissionGroup to true. In this case, the permissions of admins are disabled, making admins equivalent to ordinary group members. Conversely, setting it to false deactivates the permission group management feature and restores the permissions of admins.
    Default community permissions defaultPermissions and default topic permissions defaultPermissions are automatically created in the community information V2TIMGroupInfo and topic information V2TIMTopicInfo, which are effective for all group members everyone (excluding the group owner).
    Users can set community permissions groupPermission in permission groups V2TIMPermissionGroupInfo when creating permission groups, and then change the permissions later. Users can call the addTopicPermissionToPermissionGroup API to add topic permissions topicPermission to permission groups. The community permissions and topic permissions of a permission group are valid only for members in the group.
    Permissions are represented by a 64-bit value, with each bit representing a permission. A bit value of 0 indicates that the permission is disabled, while a bit value of 1 indicates that the permission is enabled. The table of bits for community and topic permissions is as follows. For example, if the community permission value of a permission group is set to 5 (101 in binary mode), the members in the permission group have the permissions to modify group information and manage permission group information.
    A group member's permission consists of the default everyone permission and the union of permissions from multiple permission groups that the member belongs to. That is, the group member has this permission when it is enabled anywhere.
    The group owner always has all the permissions.
    Category
    Source
    Description
    Default community permissions
    defaultPermissions in the community information V2TIMGroupInfo
    Default permissions of all community members everyone
    Permissions that can be modified by the group owners and members with the permission to modify group information
    Default topic permissions
    defaultPermissions in the topic information V2TIMTopicInfo
    Default permissions of all community members everyone in this topic
    Permissions that can be modified by the group owners and the members who previously had the topic management permission
    Community permissions of permission groups
    groupPermission of permission groups V2TIMPermissionGroupInfo
    Permissions that can be modified by the group owners and the members with the permission to manage permission group information
    Topic permissions of permission groups
    Call the addTopicPermissionToPermissionGroup API to add topicPermission to permission groups V2TIMPermissionGroupInfo
    Permissions that can be modified by the group owners and the members with the permission to manage permission group information
    The table of bits for community and topic permissions is as follows:
    Category
    Bit
    Name
    Meaning
    Community permissions
    Bit 0
    V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_INFO
    Permission to modify group information
    Bit 1
    V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_MEMBER
    Group member management permission, such as deleting members, approving group joining requests, and modifying member information
    Bit 2
    V2TIM_COMMUNITY_PERMISSION_MANAGE_PERMISSION_GROUP_INFO
    Permission to manage permission group information
    3rd bit
    V2TIM_COMMUNITY_PERMISSION_MANAGE_PERMISSION_GROUP_MEMBER
    Permission to manage permission group members
    Bit 4
    V2TIM_COMMUNITY_PERMISSION_MANAGE_TOPIC_IN_COMMUNITY
    Topic management permissions, such as creating, modifying, and deleting topics
    Bit 5
    V2TIM_COMMUNITY_PERMISSION_MUTE_MEMBER
    Permission to mute a certain group member across all topics in a community
    Bit 6
    V2TIM_COMMUNITY_PERMISSION_SEND_MESSAGE
    Permission for group members to send messages about all topics in a community
    Bit 7
    V2TIM_COMMUNITY_PERMISSION_AT_ALL
    Permission to send @all messages about all topics in a community
    Bit 8
    V2TIM_COMMUNITY_PERMISSION_GET_HISTORY_MESSAGE
    Permission to retrieve all topics-related historical messages sent before group joining in a community
    Bit 9
    V2TIM_COMMUNITY_PERMISSION_REVOKE_OTHER_MEMBER_MESSAGE
    Permission to recall others' messages about all topics in a community
    Bit 10
    V2TIM_COMMUNITY_PERMISSION_BAN_MEMBER
    Permission to ban community members
    Topic permissions
    Bit 0
    V2TIM_TOPIC_PERMISSION_MANAGE_TOPIC
    Permission to manage the current topic, including modifying the topic information and deleting the current topic
    Bit 1
    V2TIM_TOPIC_PERMISSION_MANAGE_TOPIC_PERMISSION
    Permission to manage topic permissions for the current topic, including adding, modifying, and removing topic permissions
    Bit 2
    V2TIM_TOPIC_PERMISSION_MUTE_MEMBER
    Permission to mute members in the current topic
    Bit 3
    V2TIM_TOPIC_PERMISSION_SEND_MESSAGE
    Permission to send messages in the current topic
    Bit 4
    V2TIM_TOPIC_PERMISSION_GET_HISTORY_MESSAGE
    Permission to retrieve historical messages sent before group joining in the current topic
    Bit 5
    V2TIM_TOPIC_PERMISSION_REVOKE_OTHER_MEMBER_MESSAGE
    Permission to recall others' messages in the current topic
    Bit 6
    V2TIM_TOPIC_PERMISSION_AT_ALL
    Permission to send @all messages in the current topic

    Examples

    We use a scenario to introduce the permission group usage process. A sports community involves 3 topics, including [Important Notification], [Basketball], and [Football]. All members have the permission to retrieve historical messages sent before group joining in the [Important notification] topic, and the permission to send messages in the [Basketball] and [Football] topics. Member a has the permissions to modify community information, manage group members, and send messages in the [Important notification] topic, while members b and c have the permission to mute members in the [Basketball] and [Football] topics.
    The process is as follows:
    1. This is very important: In the community, set enablePermissionGroup to true to enable the permission group feature. This step can be the last step.
    2. Set defaultPermissions to 0 to disable all the everyone permissions for communities, so no member has any community permissions.
    3. Set the everyone permissions defaultPermissions to 16 (10000 in binary mode) for the [Important Notification] topic, that is, V2TIM_TOPIC_PERMISSION_GET_HISTORY_MESSAGE. Set the everyone permissions defaultPermissions to 8 (1000 in binary mode) for the [Basketball] and [Football] topics, that is, V2TIM_TOPIC_PERMISSION_SEND_MESSAGE. In this case, all members can retrieve historical messages sent before group joining in the [Important notification] topic and send messages in the [Basketball] and [Football] topics.
    4. Create a permission group named Community Management, and set the community permission groupPermission to 3 (11 in binary mode), which is the OR operation value specified by V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_INFO | V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_MEMBER for the permission. Add the messaging permission topicPermission in the [Important notification] topic, and set it to 8 (1000 in binary mode), that is V2TIM_TOPIC_PERMISSION_SEND_MESSAGE. After being added to the permission group, group member a will have permissions to modify community information, manage group members, and send messages in the [Important notification] topic.
    5. Create a permission group named Topic Management, disable all community permissions, and set groupPermission to 0. Add the mute permission topicPermission in the [Basketball] and [Football] topics, and set it to 4 (100 in binary mode), that is V2TIM_TOPIC_PERMISSION_MUTE_MEMBER. After being added to this permission group, group members b and c will have permissions to mute members in the [Basketball] and [Football] topics.

    Community Permission Management

    Enabling/Disabling the Permission Group Feature

    Groups can be managed by either admins or permission groups. When the permission group feature is enabled, the admin role is disabled, making admins equivalent to ordinary group members. When the permission group feature is disabled, the admin permissions are restored.
    Set enablePermissionGroup (Android, iOS & Mac, Windows) to enable or disable the permission group feature. When the feature is enabled, the admin role is disabled. When the feature is disabled, the admin permissions are restored.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    V2TIMGroupInfo groupInfo = new V2TIMGroupInfo();
    groupInfo.setGroupID("ID of the community for which the permission group feature needs to be enabled");
    groupInfo.setEnablePermissionGroup(true);
    V2TIMManager.getGroupManager().setGroupInfo(groupInfo, new V2TIMCallback() {
    @Override
    public void onSuccess() {
    // The permission group feature is enabled successfully
    }
    @Override
    public void onError(int code, String desc) {
    // The permission group feature fails to be enabled
    }
    });
    
    // Group event listener
    V2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {
    @Override
    public void onGroupInfoChanged(String groupID, List<V2TIMGroupChangeInfo> changeInfos) {
    // Group information update callback
    }
    });
    V2TIMGroupInfo *info = [[V2TIMGroupInfo alloc] init];
    info.groupID = @"ID of the community for which the permission group feature needs to be enabled";
    info.enablePermissionGroup = YES;
    
    [[V2TIMManager sharedInstance] setGroupInfo:info succ:^{
    // The permission group feature is enabled successfully
    } fail:^(int code, NSString *msg) {
    // The permission group feature fails to be enabled
    }];
    
    // Group event listener
    [[V2TIMManager sharedInstance] addGroupListener:self];
    - (void)onGroupInfoChanged:(NSString *)groupID changeInfoList:(NSArray<V2TIMGroupChangeInfo *>*)changeInfoList {
    // Group information update callback
    }
    V2TIMGroupInfo info;
    info.groupID = "ID of the community for which the permission group feature needs to be enabled";
    info.enablePermissionGroup = true;
    info.modifyFlag |= (uint32_t)V2TIM_GROUP_INFO_MODIFY_FLAG_ENABLE_PERMISSION_GROUP;
    
    class TestCallBack : public V2TIMValueCallback<V2TIMString> {
    void OnSuccess(const V2TIMString &value)override {
    // The permission group feature is enabled successfully
    }
    void OnError(int error_code, const V2TIMString &error_message) override {
    // The permission group feature fails to be enabled
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetGroupManager()->SetGroupInfo(info, callback);
    
    // Group event listener
    class GroupListener final : public V2TIMGroupListener {
    public:
    GroupListener() = default;
    ~GroupListener() override = default;
    void OnGroupInfoChanged(const V2TIMString &groupID, const V2TIMGroupChangeInfoVector &changeInfos)override {
    // Group information update notification
    }
    };
    
    GroupListener groupListener;
    V2TIMManager::GetInstance()->AddGroupListener(&groupListener);

    Default Community Permissions

    Group owners and members with permission to modify group information can set defaultPermissions (Android, iOS & Mac, Windows) in V2TIMGroupInfo to change the default permissions of communities. These default permissions are effective for all group members everyone (excluding the group owner).
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    // Assume that it is required to allow all group members to send messages and retrieve historical messages sent before community joining in all topics by default, with other permissions disabled
    long communityPermission = V2TIMPermissionGroupInfo.V2TIM_COMMUNITY_PERMISSION_SEND_MESSAGE | V2TIMPermissionGroupInfo.V2TIM_COMMUNITY_PERMISSION_GET_HISTORY_MESSAGE;
    V2TIMGroupInfo groupInfo = new V2TIMGroupInfo();
    groupInfo.setGroupID("ID of the community to be modified");
    groupInfo.setDefaultPermissions(communityPermission);
    V2TIMManager.getGroupManager().setGroupInfo(groupInfo, new V2TIMCallback() {
    @Override
    public void onSuccess() {
    // Default permissions are set successfully
    }
    @Override public void onError(int code, String desc) {
    // Default permissions fail to be set
    }
    });
    
    // Group profile modification notification
    V2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {
    @Override
    public void onGroupInfoChanged(String groupID, List<V2TIMGroupChangeInfo> changeInfos) {
    // Group information update callback
    }
    });
    // Assume that it is required to allow all group members to send messages and retrieve historical messages sent before community joining in all topics by default, with other permissions disabled
    V2TIMGroupInfo *info = [[V2TIMGroupInfo alloc] init];
    info.groupID = @"ID of the community to be modified";
    info.defaultPermissions = V2TIM_COMMUNITY_PERMISSION_SEND_MESSAGE |V2TIM_COMMUNITY_PERMISSION_GET_HISTORY_MESSAGE;
    
    [[V2TIMManager sharedInstance] setGroupInfo:info succ:^{
    // Default permissions are set successfully
    } fail:^(int code, NSString *msg) {
    // Default permissions fail to be set
    }];
    
    // Group event listener
    [[V2TIMManager sharedInstance] addGroupListener:self];
    - (void)onGroupInfoChanged:(NSString *)groupID changeInfoList:(NSArray<V2TIMGroupChangeInfo *>*)changeInfoList {
    // Group profile update callback
    }
    // Assume that it is required to allow all group members to send messages and retrieve historical messages sent before community joining in all topics by default, with other permissions disabled
    V2TIMGroupInfo info;
    info.groupID = "ID of the community to be modified";
    info.modifyFlag |= (uint32_t)V2TIM_GROUP_INFO_MODIFY_FLAG_DEFAULT_PERMISSIONS;
    info.defaultPermissions = V2TIM_COMMUNITY_PERMISSION_SEND_MESSAGE |V2TIM_COMMUNITY_PERMISSION_GET_HISTORY_MESSAGE;
    
    class TestCallBack : public V2TIMValueCallback<V2TIMString> {
    void OnSuccess(const V2TIMString &value)override {
    // Default permissions are set successfully
    }
    void OnError(int error_code, const V2TIMString &error_message)override {
    // Default permissions fail to be set
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetGroupManager()->SetGroupInfo(info, callback);
    
    // Group event listener
    class GroupListener final : public V2TIMGroupListener {
    public:
    GroupListener() = default;
    ~GroupListener() override = default;
    void OnGroupInfoChanged(const V2TIMString &groupID, const V2TIMGroupChangeInfoVector &changeInfos)override {
    // Group profile update notification
    }
    };
    
    GroupListener groupListener;
    V2TIMManager::GetInstance()->AddGroupListener(&groupListener);

    Creating a Permission Group

    Group owners and members with permission to manage group information can call createPermissionGroupInCommunity (Android, iOS & Mac, Windows) to create up to 20 permission groups by default.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    V2TIMPermissionGroupInfo v2TIMPermissionGroupInfo = new V2TIMPermissionGroupInfo();
    v2TIMPermissionGroupInfo.setGroupID("ID of the community for which a permission group needs to be created");
    v2TIMPermissionGroupInfo.setPermissionGroupID("Permission group ID, which can be left blank or custom");
    v2TIMPermissionGroupInfo.setPermissionGroupName("Permission group name");
    v2TIMPermissionGroupInfo.setCustomData("Custom character string of the permission group");
    // Members of this permission group have the [permission to modify group information] and [permission to manage group members] long communityPermission =V2TIMPermissionGroupInfo.V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_INFO |V2TIMPermissionGroupInfo.V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_MEMBER;
    v2TIMPermissionGroupInfo.setGroupPermission(communityPermission);
    
    V2TIMManager.getCommunityManager().createPermissionGroupInCommunity(v2TIMPermissionGroupInfo, new V2TIMValueCallback<String>() {
    @Override
    public void onSuccess(String permissionGroupID) {
    // The permission group is created successfully
    }
    @Override
    public void onError(int code, String desc) {
    // The permission group fails to be created
    }
    });
    
    // Community group event listener
    V2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {
    @Override
    public void onCreatePermissionGroup(String groupID, V2TIMPermissionGroupInfo permissionGroupInfo) {
    // Permission group creation notification
    }
    });
    V2TIMPermissionGroupInfo *permissionGroupInfo = [[V2TIMPermissionGroupInfo alloc] init];
    permissionGroupInfo.groupID = @"ID of the community for which a permission group needs to be created";
    permissionGroupInfo.permissionGroupID = @"Permission group ID, which can be left blank or custom";
    permissionGroupInfo.permissionGroupName = @"Permission group name";
    // Members of this permission group have the [permission to modify group information] and [permission to manage group members]
    permissionGroupInfo.groupPermission = V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_INFO |V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_MEMBER;
    permissionGroupInfo.customData = @"Custom character string of the permission group";
    
    [[V2TIMManager sharedInstance] createPermissionGroupInCommunity:permissionGroupInfo succ:^(NSString *permissionGroupID) {
    // The permission group is created successfully
    } fail:^(int code, NSString *desc) {
    // The permission group fails to be created
    }];
    
    // Community event listener
    [[V2TIMManager sharedInstance] addCommunityListener:self];
    - (void)onCreatePermissionGroup:(NSString *)groupID permissionGroupInfo:(V2TIMPermissionGroupInfo *)permissionGroupInfo {
    // Permission group creation notification
    }
    V2TIMPermissionGroupInfo permissionGroupInfo;
    permissionGroupInfo.groupID = "ID of the community for which a permission group needs to be created";
    permissionGroupInfo.permissionGroupID = "Permission group ID, which can be left blank or custom";
    permissionGroupInfo.permissionGroupName = "Permission group name";
    permissionGroupInfo.customData = "Custom character string of the permission group";
    // Members of this permission group have the [permission to modify group information] and [permission to manage group members]
    permissionGroupInfo.groupPermission = V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_INFO |V2TIM_COMMUNITY_PERMISSION_MANAGE_GROUP_MEMBER;
    
    class TestCallBack : public V2TIMValueCallback<V2TIMString> {
    void OnSuccess(const V2TIMString &value) override {
    // The permission group is created successfully
    }
    void OnError(int error_code, const V2TIMString &error_message) override {
    // The permission group fails to be created
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetCommunityManager()->CreatePermissionGroupInCommunity(permissionGroupInfo, callback);
    
    // Community event listener
    class CommunityListener final : public V2TIMCommunityListener {
    public:
    CommunityListener() = default;
    ~CommunityListener() override = default;
    void OnCreatePermissionGroup(const V2TIMString &groupID, const V2TIMPermissionGroupInfo &permissionGroupInfo) override {
    // Permission group creation notification
    }
    };
    
    CommunityListener communityListener;
    V2TIMManager::GetInstance()->GetCommunityManager()->AddCommunityListener(&communityListener);

    Deleting a Permission Group

    Group owners and members with the permission to manage group information can call deletePermissionGroupFromCommunity (Android, iOS & Mac, Windows) to delete permission groups.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    List<String> deleteList = new ArrayList<>();
    deleteList.add("ID of permission group 1");
    deleteList.add("ID of permission group 2");
    
    V2TIMManager.getCommunityManager().deletePermissionGroupFromCommunity("ID of the community for which a permission group needs to be deleted", deleteList, new V2TIMValueCallback<List<V2TIMPermissionGroupOperationResult>>() {
    @Override
    public void onSuccess(List<V2TIMPermissionGroupOperationResult> results) {
    // Deletion is successful, and results specifies the operation results for each permission group
    }
    @Override public void onError(int code, String desc) {
    // Deletion fails
    }
    });
    
    // Community group event listener
    V2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {
    @Override
    public void onDeletePermissionGroup(String groupID, List<String> permissionGroupIDList) {
    // Permission group deletion notification
    }
    });
    NSMutableArray *deleteList = [NSMutableArray array];
    [deleteList addObject:@"ID of permission group 1"];
    [deleteList addObject:@"ID of permission group 2"];
    
    [[V2TIMManager sharedInstance] deletePermissionGroupFromCommunity:@"ID of the community for which a permission group needs to be deleted" permissionGroupIDList:deleteList succ:^(NSMutableArray<V2TIMPermissionGroupOperationResult *> *resultList) {
    // Deletion is successful, and resultList specifies the operation results for each permission group
    } fail:^(int code, NSString *desc) {
    // Deletion fails
    }];
    
    // Community event listener
    [[V2TIMManager sharedInstance] addCommunityListener:self];
    - (void)onDeletePermissionGroup:(NSString *)groupID permissionGroupIDList:(NSArray<NSString *>*)permissionGroupIDList {
    // Permission group deletion notification
    }
    V2TIMStringVector permissionGroupIDList;
    permissionGroupIDList.PushBack("ID of permission group 1");
    permissionGroupIDList.PushBack("ID of permission group 2");
    
    class TestCallBack : public V2TIMValueCallback<V2TIMPermissionGroupOperationResultVector> {
    void OnSuccess(const V2TIMPermissionGroupOperationResultVector &value) override {
    // Deletion is successful, and results specifies the operation results for each permission group
    }
    void OnError(int error_code, const V2TIMString &error_message) override {
    // Deletion fails
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetCommunityManager()->DeletePermissionGroupFromCommunity("ID of the community for which a permission group needs to be deleted", permissionGroupIDList, callback);
    
    // Community event listener
    class CommunityListener final : public V2TIMCommunityListener {
    public:
    CommunityListener() = default;
    ~CommunityListener() override = default;
    void OnDeletePermissionGroup(const V2TIMString &groupID, const V2TIMStringVector &permissionGroupIDList)override {
    // Permission group deletion notification
    }
    };
    
    CommunityListener communityListener;
    V2TIMManager::GetInstance()->GetCommunityManager()->AddCommunityListener(&communityListener);

    Modifying a Permission Group

    Group owners and members with the permission to manage group information can call modifyPermissionGroupInfoInCommunity (Android, iOS & Mac, Windows) to change the name, permissions, and custom fields for a permission group.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    V2TIMPermissionGroupInfo v2TIMPermissionGroupInfo = new V2TIMPermissionGroupInfo();
    v2TIMPermissionGroupInfo.setGroupID("ID of the community for which a permission group needs to be modified"); // Required
    v2TIMPermissionGroupInfo.setPermissionGroupID("ID of the permission group to be modified"); // Required
    v2TIMPermissionGroupInfo.setPermissionGroupName("Name of the permission group to be modified");
    // Members in this permission group have the [permission to manage group information] and [permission to manage members in permission groups]
    long communityPermission =V2TIMPermissionGroupInfo.V2TIM_COMMUNITY_PERMISSION_MANAGE_PERMISSION_GROUP_INFO |V2TIMPermissionGroupInfo.V2TIM_COMMUNITY_PERMISSION_MANAGE_PERMISSION_GROUP_MEMBER;
    v2TIMPermissionGroupInfo.setGroupPermission(communityPermission);
    v2TIMPermissionGroupInfo.setCustomData("Custom character string to be modified");
    
    V2TIMManager.getCommunityManager().modifyPermissionGroupInfoInCommunity(v2TIMPermissionGroupInfo, newV2TIMCallback() {
    @Override
    public void onSuccess() {
    // Permission group information is modified successfully
    }
    @Override
    public void onError(int code, String desc) {
    // Permission group information fails to be modified
    }
    });
    
    // Community group event listener
    V2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {
    @Override
    public void onChangePermissionGroupInfo(String groupID, V2TIMPermissionGroupInfo permissionGroupInfo) {
    // Permission group update notification
    }
    });
    V2TIMPermissionGroupInfo *permissionGroupInfo = [[V2TIMPermissionGroupInfo alloc] init];
    permissionGroupInfo.groupID = @"ID of the community for which a permission group needs to be modified"; // Required
    permissionGroupInfo.permissionGroupID = @"ID of the permission group to be modified"; // Required
    permissionGroupInfo.permissionGroupName = @"Name of the permission group to be modified";
    permissionGroupInfo.customData = @"Custom character string to be modified";
    // Members in this permission group have the [permission to manage group information] and [permission to manage members in permission groups]
    permissionGroupInfo.groupPermission =V2TIM_COMMUNITY_PERMISSION_MANAGE_PERMISSION_GROUP_INFO |V2TIM_COMMUNITY_PERMISSION_MANAGE_PERMISSION_GROUP_MEMBER;
    
    [[V2TIMManager sharedInstance] modifyPermissionGroupInfoInCommunity:permissionGroupInfo succ:^{
    // Permission group information is modified successfully
    } fail:^(int code, NSString *desc) {
    // Permission group information fails to be modified
    }];
    
    // Community event listener
    [[V2TIMManager sharedInstance] addCommunityListener:self];
    - (void)onChangePermissionGroupInfo:(NSString *)groupID permissionGroupInfo:(V2TIMPermissionGroupInfo *)permissionGroupInfo {
    // Permission group update notification
    }
    V2TIMPermissionGroupInfo modifyInfo;
    modifyInfo.groupID = "ID of the community for which a permission group needs to be modified"; // Required
    modifyInfo.permissionGroupID = "ID of the permission group to be modified"; // Required
    modifyInfo.permissionGroupName = "Name of the permission group to be modified";
    modifyInfo.customData = "Custom character string to be modified";
    // Members in this permission group have the [permission to manage group information] and [permission to manage members in permission groups]
    modifyInfo.groupPermission = V2TIM_COMMUNITY_PERMISSION_MANAGE_PERMISSION_GROUP_INFO | V2TIM_COMMUNITY_PERMISSION_MANAGE_PERMISSION_GROUP_MEMBER;
    modifyInfo.modifyFlag = V2TIMPermissionGroupInfoModifyFlag::V2TIM_PERMISSION_MODIFY_FLAG_NAME
    | V2TIMPermissionGroupInfoModifyFlag::V2TIM_PERMISSION_MODIFY_FLAG_GROUP_PERMISSION
    | V2TIMPermissionGroupInfoModifyFlag::V2TIM_PERMISSION_MODIFY_FLAG_CUSTOM_DATA;
    
    class TestCallBack : public V2TIMValueCallback<V2TIMString> {
    void OnSuccess(const V2TIMString &value) override {
    // Permission group information is modified successfully
    }
    void OnError(int error_code, const V2TIMString &error_message) override {
    // Permission group information fails to be modified
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetCommunityManager()->ModifyPermissionGroupInfoInCommunity(modifyInfo, new CppAPITestImpl::Callback("ModifyPermissionGroupInfoInCommunity"));
    
    // Community event listener
    class CommunityListener final : public V2TIMCommunityListener {
    public:
    CommunityListener() = default;
    ~CommunityListener() override = default;
    void OnChangePermissionGroupInfo(const V2TIMString &groupID, const V2TIMPermissionGroupInfo &permissionGroupInfo) override {
    // Permission group update notification
    }
    };
    
    CommunityListener communityListener;
    V2TIMManager::GetInstance()->GetCommunityManager()->AddCommunityListener(&communityListener);

    Accessing a Permission Group List

    Accessing a Permission Group List

    Group members can call getPermissionGroupListInCommunity (Android, iOS & Mac, Windows) to access the permission group list. When the parameter permissionGroupIDList is not empty, you can access a specified permission group list. When permissionGroupIDList is empty, you can access all permission group lists.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    List<String> permissionGroupIDList = new ArrayList<>();
    // When permissionGroupIDList is set to a value, you can access a specified permission group list. When permissionGroupIDList is empty, you can access all permission group lists
    permissionGroupIDList.add("ID of the permission group to access");
    
    V2TIMManager.getCommunityManager().getPermissionGroupListInCommunity("ID of the community for which the permission group list needs to be accessed", permissionGroupIDList, newV2TIMValueCallback<List<V2TIMPermissionGroupInfoResult>>() {
    @Override
    public voidonSuccess(List<V2TIMPermissionGroupInfoResult> resultList) {
    // The permission group list is successfully accessed
    }
    @Override public void onError(int code, String desc) {
    // The permission group list fails to be accessed
    }
    });
    NSMutableArray *permissionGroupIDList = [NSMutableArray array];
    // When permissionGroupIDList is set to a value, you can access a specified permission group list. When permissionGroupIDList is empty, you can access all permission group lists
    [permissionGroupIDList addObject:@"The ID of the permission group to access"];
    
    [[V2TIMManager sharedInstance] getPermissionGroupListInCommunity:@"ID of the community for which the permission group list needs to be accessed" permissionGroupIDList:permissionGroupIDList succ:^(NSMutableArray<V2TIMPermissionGroupInfoResult *>*resultList) {
    // The permission group list is successfully accessed
    } fail:^(int code, NSString *desc) {
    // The permission group list fails to be accessed
    }];
    V2TIMStringVector permissionGroupIDList;
    // When permissionGroupIDList is set to a value, you can access a specified permission group list. When permissionGroupIDList is empty, you can access all permission group lists
    permissionGroupIDList.PushBack("The ID of the permission group to access");
    
    class TestCallBack : public V2TIMValueCallback<V2TIMPermissionGroupInfoResultVector> {
    void OnSuccess(constV2TIMPermissionGroupInfoResultVector &value) override {
    // The permission group list is successfully accessed
    }
    void OnError(int error_code,const V2TIMString &error_message) override {
    // The permission group list fails to be accessed
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetCommunityManager()->GetPermissionGroupListInCommunity("ID of the community for which the permission group list needs to be accessed", permissionGroupIDList, callback);

    Accessing the List of Joined Permission Groups

    Community members can call getJoinedPermissionGroupListInCommunity (Android, iOS & Mac, Windows) to access the list of joined permission groups.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    V2TIMManager.getCommunityManager().getJoinedPermissionGroupListInCommunity("ID of the community for which the permission group list needs to be accessed", new V2TIMValueCallback<List<V2TIMPermissionGroupInfoResult>>() {
    @Override public voidonSuccess(List<V2TIMPermissionGroupInfoResult> resultList) {
    // The joined permission group is successfully accessed
    }
    @Override public voidonError(int code, String desc) {
    // The joined permission group fails to be accessed
    }
    });
    [[V2TIMManager sharedInstance] getJoinedPermissionGroupListInCommunity:@"ID of the community for which the permission group list needs to be accessed"succ:^(NSMutableArray<V2TIMPermissionGroupInfoResult *> *resultList) {
    // The joined permission group is successfully accessed
    } fail:^(int code, NSString *desc) {
    // The joined permission group fails to be accessed
    }];
    class TestCallBack : public V2TIMValueCallback<V2TIMPermissionGroupInfoResultVector> {
    void OnSuccess(constV2TIMPermissionGroupInfoResultVector &value) override {
    // The joined permission group is successfully accessed
    }
    void OnError(interror_code, const V2TIMString &error_message) override {
    // The joined permission group fails to be accessed
    }
    };
    auto *callback = newTestCallBack;
    V2TIMManager::GetInstance()->GetCommunityManager()->GetJoinedPermissionGroupListInCommunity("ID of the community for which the permission group list needs to be accessed", callback);
    

    Adding Members to a Permission Group

    Group owners and members with the permission to manage permission groups can call addCommunityMembersToPermissionGroup (Android, iOS & Mac, Windows) to add up to 20 members to a permission group at a time.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    List<String> memberList = new ArrayList<>();
    // Up to 20 members can be added at a time
    memberList.add("userID of group member 1 to add");
    memberList.add("userID of group member 2 to add");
    
    V2TIMManager.getCommunityManager().addCommunityMembersToPermissionGroup("ID of the community for which members need to be added to a permission group", "ID of the permission group where members need to be added", memberList,new V2TIMValueCallback<List<V2TIMPermissionGroupMemberOperationResult>>() {
    @Override public voidonSuccess(List<V2TIMPermissionGroupMemberOperationResult> resultList) {
    // Members are successfully added
    }
    
    @Override publicvoid onError(int code, String desc) {
    // Members fail to be added
    }
    });
    
    // Community event listener
    V2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {
    @Override
    public void onAddMembersToPermissionGroup(String groupID, String permissionGroupID, List<String>memberIDList){
    // Notification for adding permission group members
    }
    });
    NSMutableArray *memberList = [NSMutableArray array];
    [memberList addObject:@"userID of group member 1 to add"];
    [memberList addObject:@"userID of group member 2 to add"];
    
    [[V2TIMManager sharedInstance] addCommunityMembersToPermissionGroup:@"ID of the community for which members need to be added to a permission group" permissionGroupID:@"ID of the permission group where members need to be added" memberList:memberList succ:^(NSMutableArray<V2TIMPermissionGroupMemberOperationResult *>*resultList) {
    // Members are successfully added
    } fail:^(int code, NSString *desc) {
    // Members fail to be added
    }];
    
    // Community event listener
    [[V2TIMManager sharedInstance] addCommunityListener:self];
    - (void)onAddMembersToPermissionGroup:(NSString *)groupID permissionGroupID:(NSString *)permissionGroupID memberIDList:(NSArray<NSString *> *)memberIDList {
    // Notification for adding permission group members
    }
    V2TIMStringVector memberIDList;
    memberIDList.PushBack("userID of group member 1 to add");
    memberIDList.PushBack("userID of group member 2 to add");
    
    class TestCallBack : public V2TIMValueCallback<V2TIMPermissionGroupMemberOperationResultVector> {
    void OnSuccess(constV2TIMPermissionGroupMemberOperationResultVector &value) override {
    // Members are successfully added
    }
    void OnError(interror_code, const V2TIMString &error_message) override {
    // Members fail to be added
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetCommunityManager()->AddCommunityMembersToPermissionGroup("ID of the community for which members need to be added to a permission group", "ID of the permission group where members need to be added", memberIDList, callback);
    
    // Community event listener
    class CommunityListener final : public V2TIMCommunityListener {
    public:
    CommunityListener() = default;
    ~CommunityListener() override = default;
    void OnAddMembersToPermissionGroup(const V2TIMString &groupID, const V2TIMString &permissionGroupID,const V2TIMStringVector &memberIDList) override {
    // Notification for adding permission group members
    }
    };
    
    CommunityListener communityListener;
    V2TIMManager::GetInstance()->GetCommunityManager()->AddCommunityListener(&communityListener);

    Removing Members from a Permission Group

    Group owners and members with the permission to manage permission group members can call removeCommunityMembersFromPermissionGroup (Android, iOS & Mac, Windows) to remove members from a permission group.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    List<String> memberList = new ArrayList<>();
    memberList.add("userID of group member 1 to remove");
    memberList.add("userID of group member 2 to remove");
    
    V2TIMManager.getCommunityManager().removeCommunityMembersFromPermissionGroup("ID of the community from which permission group members need to be removed", "ID of the permission group from which members need to be removed", memberList, new V2TIMValueCallback<List<V2TIMPermissionGroupMemberOperationResult>>() {
    @Override public void onSuccess(List<V2TIMPermissionGroupMemberOperationResult> resultList) {
    // Group members are successfully removed
    }
    @Override public void onError(int code, String desc) {
    // Group members fail to be removed
    }
    });
    
    // Community group event listener
    V2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {
    @Override
    public void onRemoveMembersFromPermissionGroup(String groupID, String permissionGroupID,List<String>memberIDList) {
    // Notification of removing members from a permission group
    }
    });
    NSMutableArray *memberList = [NSMutableArray array];
    [memberList addObject:@"userID of group member 1 to remove"];
    [memberList addObject:@"userID of group member 2 to remove"];
    
    [[V2TIMManager sharedInstance] removeCommunityMembersFromPermissionGroup:@"ID of the community from which permission group members need to be removed" permissionGroupID:@"ID of the permission group from which members need to be removed" memberList:memberList succ:^(NSMutableArray<V2TIMPermissionGroupMemberOperationResult *> *resultList) {
    // Group members are successfully removed
    } fail:^(int code, NSString *desc) {
    // Group members fail to be removed
    }];
    
    // Community event listener
    [[V2TIMManager sharedInstance] addCommunityListener:self];
    - (void)onRemoveMembersFromPermissionGroup:(NSString *)groupID permissionGroupID:(NSString *)permissionGroupID memberIDList:(NSArray<NSString *> *)memberIDList {
    // Notification of removing members from a permission group
    }
    V2TIMStringVector memberIDList;
    memberIDList.PushBack("userID of group member 1 to remove");
    memberIDList.PushBack("userID of group member 2 to remove"); class TestCallBack : public V2TIMValueCallback<V2TIMPermissionGroupMemberOperationResultVector> {
    void OnSuccess(constV2TIMPermissionGroupMemberOperationResultVector &value) override {
    // Group members are successfully removed
    }
    void OnError(interror_code, const V2TIMString &error_message) override {
    // Group members fail to be removed
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetCommunityManager()->RemoveCommunityMembersFromPermissionGroup("ID of the community from which permission group members need to be removed", "ID of the permission group from which members need to be removed", memberIDList, callback);
    
    // Community event listener
    class CommunityListener final : public V2TIMCommunityListener {
    public:
    CommunityListener() = default;
    ~CommunityListener() override = default;
    void OnRemoveMembersFromPermissionGroup(const V2TIMString &groupID, const V2TIMString &permissionGroupID, const V2TIMStringVector &memberIDList) override {
    // Notification of removing members from a permission group
    }
    };
    
    CommunityListener communityListener;
    V2TIMManager::GetInstance()->GetCommunityManager()->AddCommunityListener(&communityListener);

    Accessing a Permission Group Member List

    Call getCommunityMemberListInPermissionGroup (Android, iOS & Mac, Windows) to access the member list in a permission group, where the parameter nextCursor indicates the continued pulling cursor. Fill in an empty character string for the first pulling, and fill in the return value from the last call output for continued pulling.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    V2TIMManager.getCommunityManager().getCommunityMemberListInPermissionGroup("ID of the community for which the permission group members need to be accessed", "ID of the permission group from which members need to be accessed", "", newV2TIMValueCallback<V2TIMPermissionGroupMemberInfoResult>() {
    @Override
    public void onSuccess(V2TIMPermissionGroupMemberInfoResult result) {
    // The member list in a permission group is successfully accessed, where result.getNextCursor() returns the continued pulling cursor. Fill in the return value when re-calling this API for continued pulling
    }
    @Override
    public void onError(int code, String desc) {
    // The member list in a permission group fails to be accessed
    }
    });
    [[V2TIMManager sharedInstance] getCommunityMemberListInPermissionGroup:@"ID of the community for which the permission group members need to be accessed"permissionGroupID:@"ID of the permission group from which members need to be accessed" nextCursor:@"" succ:^(NSString *nextCursor,NSMutableArray<V2TIMGroupMemberFullInfo *>*resultList) {
    // The member list in a permission group is successfully accessed, where nextCursor returns the continued pulling cursor. Fill in the return value when re-calling this API for continued pulling
    } fail:^(int code, NSString *desc) {
    // The member list in a permission group fails to be accessed
    }];
    class TestCallBack : public V2TIMValueCallback<V2TIMPermissionGroupMemberInfoResult> {
    void OnSuccess(constV2TIMPermissionGroupMemberInfoResult &value) override {
    // The member list in a permission group is successfully accessed, where value.nextCursor returns the continued pulling cursor. Fill in the return value when re-calling the API for continued pulling
    }
    void OnError(int error_code, constV2TIMString &error_message) override {
    // The member list in a permission group fails to be accessed
    }
    };
    auto *callback = new TestCallBack;
    V2TIMManager::GetInstance()->GetCommunityManager()->GetCommunityMemberListInPermissionGroup("ID of the community for which the permission group members need to be accessed", "ID of the permission group from which members need to be accessed", "", callback);

    Topic Permission Management

    Default Topic Permission

    Group owners and members with the topic management permission can call setTopicInfo (Android, iOS & Mac, Windows) to modify the default permission of a topic. The default permission of the topic applies to all group members (excluding the group owner).
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    // Assume that it is required for all community members to have permissions to send messages in the current topic and retrieve historical messages sent before community joining in the topic
    long topicPermission = V2TIMPermissionGroupInfo.V2TIM_TOPIC_PERMISSION_SEND_MESSAGE |V2TIMPermissionGroupInfo.V2TIM_TOPIC_PERMISSION_GET_HISTORY_MESSAGE;
    V2TIMTopicInfo topicInfo = new V2TIMTopicInfo();
    topicInfo.setTopicID("ID of the topic for which the default topic permission needs to be set");
    topicInfo.setDefaultPermissions(topicPermission);
    
    V2TIMManager.getCommunityManager().setTopicInfo(topicInfo,new V2TIMCallback() {
    @Override
    public void onSuccess() {
    // The default topic permission is successfully modified
    }
    @Override public voidonError(int code, String desc) {
    // The default topic permission fails to be modified
    }
    });
    
    // Community group event listener
    V2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {
    @Override
    public void onChangeTopicInfo(String groupID, V2TIMTopicInfo topicInfo) {
    // Topic information update notification
    }
    });
    // Assume that it is required for all community members to have permissions to send messages in the current topic and retrieve historical messages sent before community joining in the topic
    V2TIMTopicInfo *info = [[V2TIMTopicInfo alloc] init];
    info.topicID = @"ID of the topic for which the default topic permission needs to be set";
    info.defaultPermissions = V2TIM_TOPIC_PERMISSION_SEND_MESSAGE |V2TIM_TOPIC_PERMISSION_GET_HISTORY_MESSAGE;
    
    [[V2TIMManager sharedInstance] setTopicInfo:info succ:^{
    // The default topic permission is successfully modified
    } fail:^(int code, NSString *desc) {
    // The default topic permission fails to be modified
    }];
    
    // Community event listener
    [[V2TIMManager sharedInstance] addCommunityListener:self];
    - (void)onChangeTopicInfo:(NSString *)groupID topicInfo:(V2TIMTopicInfo *)topicInfo {
    // Topic information update notification
    }
    // Assume that it is required for all community members to have permissions to send messages in the current topic and retrieve historical messages sent before community joining in the topic
    V2TIMTopicInfo topicInfo;
    topicInfo.topicID = "ID of the topic for which the default topic permission needs to be set";
    topicInfo.defaultPermissions = V2TIM_TOPIC_PERMISSION_SEND_MESSAGE |V2TIM_TOPIC_PERMISSION_GET_HISTORY_MESSAGE;
    topicInfo.modifyFlag = V2TIM_COMMUNITY_MODIFY_FLAG_DEFAULT_PERMISSIONS;
    
    class TestCallBack : public V2TIMValueCallback<V2TIMString> {
    void OnSuccess(const V2TIMString &value)override {
    // The default topic permission is successfully modified
    }
    void OnError(int error_code, const V2TIMString &error_message) override {
    // The default topic permission fails to be modified
    }
    };
    auto *callback = new TestCallBack; V2TIMManager::GetInstance()->GetGroupManager()->SetTopicInfo(topicInfo,callback);
    
    // Community event listener
    class CommunityListener final : public V2TIMCommunityListener {
    public:
    CommunityListener() = default;
    ~CommunityListener() override = default;
    void OnChangeTopicInfo(const V2TIMString &groupID, const V2TIMTopicInfo &topicInfo) override {
    // Topic information update notification
    }
    };
    
    CommunityListener communityListener;
    V2TIMManager::GetInstance()->GetCommunityManager()->AddCommunityListener(&communityListener);

    Adding Topic Permissions to a Permission Group

    Group owners and members with the permission to manage group information can call addTopicPermissionToPermissionGroup (Android, iOS & Mac, Windows) to add topic permissions to a permission group. These permissions are effective for members of the permission group.
    The sample code is as follows:
    Android
    iOS & Mac
    Windows
    // Assume that it is required for members in the permission group to have the [permission to manage topic 1], [permission to mute members in topic 1], as well as the [permission to manage topic 2] and [permission to revoke others' messages in topic 2]
    long topicPermission1 = V2TIMPermissionGroupInfo.V2TIM_TOPIC_PERMISSION_MANAGE_TOPIC |V2TIMPermissionGroupInfo.V2TIM_TOPIC_PERMISSION_MUTE_MEMBER;
    long topicPermission2 = V2TIMPermissionGroupInfo.V2TIM_TOPIC_PERMISSION_MANAGE_TOPIC |V2TIMPermissionGroupInfo.V2TIM_TOPIC_PERMISSION_REVOKE_OTHER_MEMBER_MESSAGE;
    HashMap<String, Long> topicPermissionMap = new HashMap<>();
    topicPermissionMap.put("ID of topic 1",topicPermission1);
    topicPermissionMap.put("ID of topic 2", topicPermission2);
    
    V2TIMManager.getCommunityManager().addTopicPermissionToPermissionGroup("ID of the community for which topic permissions need to be added", "ID of the permission group for which topic permissions need to be added",topicPermissionMap, new V2TIMValueCallback<List<V2TIMTopicOperationResult>>() {
    @Override
    public void onSuccess(List<V2TIMTopicOperationResult> v2TIMTopicOperationResults) {
    // Topic permissions are successfully added, with the parameter including the results of adding various topic permissions
    }
    @Override public void onError(int code, String desc) {
    // Topic permissions fail to be added
    }
    });
    
    // Community group event listener
    V2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {
    @Override
    public void onAddTopicPermission(String groupID, String permissionGroupID, HashMap<String, Long>topicPermissionMap