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: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.V2TIMGroupInfo
and topic information V2TIMTopicInfo
, which are effective for all group members everyone (excluding the group owner).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.Category | Source | Description |
Default community permissions | Valid when the permission group feature is enabled 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 | Valid when the permission group feature is enabled 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 | Valid when the permission group feature is enabled Permissions of members in permission groups 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 | Valid when the permission group feature is enabled Permissions of members in the permission group Permissions that can be modified by the group owners and the members with the permission to manage permission group information |
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 |
enablePermissionGroup
to true
to enable the permission group feature. This step can be the last step.defaultPermissions
to 0 to disable all the everyone permissions for communities, so no member has any community 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.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.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.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.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() {@Overridepublic void onSuccess() {// The permission group feature is enabled successfully}@Overridepublic void onError(int code, String desc) {// The permission group feature fails to be enabled}});// Group event listenerV2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {@Overridepublic 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 listenerclass 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);
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).// 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 disabledlong 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() {@Overridepublic void onSuccess() {// Default permissions are set successfully}@Override public void onError(int code, String desc) {// Default permissions fail to be set}});// Group profile modification notificationV2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {@Overridepublic 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 disabledV2TIMGroupInfo *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 disabledV2TIMGroupInfo 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 listenerclass 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);
createPermissionGroupInCommunity
(Android, iOS & Mac, Windows) to create up to 20 permission groups by default.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>() {@Overridepublic void onSuccess(String permissionGroupID) {// The permission group is created successfully}@Overridepublic void onError(int code, String desc) {// The permission group fails to be created}});// Community group event listenerV2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {@Overridepublic 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 listenerclass 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);
deletePermissionGroupFromCommunity
(Android, iOS & Mac, Windows) to delete permission groups.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>>() {@Overridepublic 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 listenerV2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {@Overridepublic 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 listenerclass 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);
modifyPermissionGroupInfoInCommunity
(Android, iOS & Mac, Windows) to change the name, permissions, and custom fields for a permission group.V2TIMPermissionGroupInfo v2TIMPermissionGroupInfo = new V2TIMPermissionGroupInfo();v2TIMPermissionGroupInfo.setGroupID("ID of the community for which a permission group needs to be modified"); // Requiredv2TIMPermissionGroupInfo.setPermissionGroupID("ID of the permission group to be modified"); // Requiredv2TIMPermissionGroupInfo.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() {@Overridepublic void onSuccess() {// Permission group information is modified successfully}@Overridepublic void onError(int code, String desc) {// Permission group information fails to be modified}});// Community group event listenerV2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {@Overridepublic 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"; // RequiredpermissionGroupInfo.permissionGroupID = @"ID of the permission group to be modified"; // RequiredpermissionGroupInfo.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"; // RequiredmodifyInfo.permissionGroupID = "ID of the permission group to be modified"; // RequiredmodifyInfo.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 listenerclass 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);
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.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 listspermissionGroupIDList.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>>() {@Overridepublic 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 listspermissionGroupIDList.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);
getJoinedPermissionGroupListInCommunity
(Android, iOS & Mac, Windows) to access the list of joined permission groups.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);
addCommunityMembersToPermissionGroup
(Android, iOS & Mac, Windows) to add up to 20 members to a permission group at a time.List<String> memberList = new ArrayList<>();// Up to 20 members can be added at a timememberList.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 listenerV2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {@Overridepublic 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 listenerclass 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);
removeCommunityMembersFromPermissionGroup
(Android, iOS & Mac, Windows) to remove members from a permission group.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 listenerV2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {@Overridepublic 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 listenerclass 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);
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.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>() {@Overridepublic 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}@Overridepublic 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);
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).// 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 topiclong 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() {@Overridepublic 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 listenerV2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {@Overridepublic 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 topicV2TIMTopicInfo *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 topicV2TIMTopicInfo 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 listenerclass 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);
addTopicPermissionToPermissionGroup
(Android, iOS & Mac, Windows) to add topic permissions to a permission group. These permissions are effective for members of the permission group.// 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>>() {@Overridepublic 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 listenerV2TIMManager.getCommunityManager().addCommunityListener(new V2TIMCommunityListener() {@Overridepublic void onAddTopicPermission(String groupID, String permissionGroupID, HashMap<String, Long>topicPermissionMap) {// Topic permission adding notification}});