TencentImSDKPlugin.v2TIMManager.getGroupManager() core class.TencentImSDKPlugin.v2TIMManager.getMessageManager() core class.// Create a topic-enabled communityfinal info = V2TimGroupInfo(groupID: "",groupType: GroupType.Community,isSupportTopic: true,groupName: "testGroup",);await TencentImSDKPlugin.v2TIMManager.getCommunityManager().createCommunity(info: info,memberList: memberList,);
// Getting the list of community groups joinedV2TimValueCallback<List<V2TimGroupInfo>> groupList = await TencentImSDKPlugin.v2TIMManager.getCommunityManager().getJoinedCommunityList();
Category | Feature | API |
Community group management | ||
| ||
| ||
| ||
| ||
Community group member management | ||
| ||
| ||
| ||
V2TIMTopicInfo (Details) object.createTopicInCommunity (Details) API to create a topic.// Create a topiccommunityManager.createTopicInCommunity(groupID: "groupID", topicInfo: V2TimTopicInfo.fromJson({"topicName":"topic"}));
// Delete a topiccommunityManager.deleteTopicFromCommunity(groupID: "",topicIDList:["topicID"]);
V2TIMTopicInfo (Details) object and modify fields as needed.setTopicInfo (Details) API to modify topic information.// Modify topic informationcommunityManager.setTopicInfo(topicInfo:V2TimTopicInfo.fromJson({"topicName":"topicName"}));
topicIDList is an empty array, the list of all topics of the community group will be got.topicIDList is the ID of specified topics, the list of the specified topics will be got.// Get the topic listgroupManager.getTopicInfoList(groupID: "",topicIDList: ['topicID']);

customInfo of a community saves the topic group list of the community, while the customString field of each topic stores the topic group.customInfo field for the topic group list of the community (group) is used to display the group list. We recommend you store the field in the List<String> format.customString of V2TimTopicInfo.key value of the customInfo field for the topic group list of the community (group).
The following sample code names it topic_category.getCommunityCategoryList(String groupID) method. Sample code:getCommunityCategoryList(String groupID) async {final Map<String, String>? customInfo = await getCommunityCustomInfo(groupID);if(customInfo != null){final String? categoryListString = customInfo["topic_category"];if(categoryListString != null && categoryListString.isNotEmpty){return jsonDecode(categoryListString);}}}Future<Map<String, String>?> getCommunityCustomInfo(String groupID) async {V2TimValueCallback<List<V2TimGroupInfoResult>> res =await TencentImSDKPlugin.v2TIMManager.getGroupManager().getGroupsInfo(groupIDList: [groupID]);if(res.code != 0){final V2TimGroupInfoResult? groupInfo = res.data?[0];if(groupInfo != null){Map<String, String>? customInfo = groupInfo.groupInfo?.customInfo;return customInfo;}}return null;}
customInfo in groupInfo. Here is a Map, and the key value is the name of the field for the topic group list you defined.getCommunityCustomInfo method is implemented in the above section. Sample code:setCommunityCategoryList(String groupID, String groupType, List<String> newCategoryList) async {final Map<String, String>? customInfo = await getCommunityCustomInfo(groupID);customInfo?["topic_category"] = jsonEncode(newCategoryList);TencentImSDKPlugin.v2TIMManager.getGroupManager().setGroupInfo(info: V2TimGroupInfo(customInfo: customInfo,groupID: groupID,groupType: groupType,// ...Other profiles));}
V2TimTopicInfo customString.
For example, the recommended format for categoryName in the code below is {"category":"Group 1"}.addCategoryForTopic(String groupID, String categoryName) {TencentImSDKPlugin.v2TIMManager.getGroupManager().setTopicInfo(topicInfo: V2TimTopicInfo(customString: categoryName),groupID: groupID, // Group ID of the topic);}
V2TIMCommunityListener (Details), topic related callback methods onCreateTopic,onDeleteTopic,onChangeTopicInfo are added for topic event listening. V2TIMCommunityListenerv2TIMCommunityListener= newV2TIMCommunityListener() {onCreateTopic(String groupID, String topicID) {// Listen for topic creation notifications}onDeleteTopic(String groupID, List<String> topicIDList) {// Listen for topic deletion notifications}onChangeTopicInfo(String groupID, V2TIMTopicInfo topicInfo) {// Listen for topic information update notifications}};TencentImSDKPlugin.v2TIMManager.getCommunityManager().addCommunityListener(listener:v2TIMCommunityListener);
Feature | API | Description |
Sends a message | Set `groupID` to the topic ID. | |
Receives a message | Set `groupID` in the message to the topic ID. | |
Marks a message as read | Set `groupID` to the topic ID. | |
Gets historical messages | Set `groupID` to the topic ID. | |
Recalls a message | Set `groupID` to the topic ID. |
フィードバック