TencentImSDKPlugin.v2TIMManager.getGroupManager() 中。 TencentImSDKPlugin.v2TIMManager.getMessageManager() 中。// 创建支持话题的社群final info = V2TimGroupInfo(groupID: "",groupType: GroupType.Community,isSupportTopic: true,groupName: "testGroup",);await TencentImSDKPlugin.v2TIMManager.getCommunityManager().createCommunity(info: info,memberList: memberList,);
// 获取加入的社群列表V2TimValueCallback<List<V2TimGroupInfo>> groupList = await TencentImSDKPlugin.v2TIMManager.getCommunityManager().getJoinedCommunityList();
V2TIMTopicInfo (Details) 对象。createTopicInCommunity (Details) 接口创建话题。// 创建话题communityManager.createTopicInCommunity(groupID: "groupID", topicInfo: V2TimTopicInfo.fromJson({"topicName":"topic"}));
// 删除话题communityManager.deleteTopicFromCommunity(groupID: "",topicIDList:["topicID"]);
V2TIMTopicInfo (Details) 对象,并设置需要修改的字段。setTopicInfo (Details) 接口修改话题信息。// 修改话题信息communityManager.setTopicInfo(topicInfo:V2TimTopicInfo.fromJson({"topicName":"topicName"}));
// 获取话题列表groupManager.getTopicInfoList(groupID: "",topicIDList: ['topicID']);

customInfo 的话题分组列表字段,展示分组。该字段建议用 List<String> 形式存储。V2TimTopicInfo 的 customString 获得每个话题所属分组。getCommunityCategoryList(String groupID) 方法,示例代码如下: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;}
groupInfo 的 customInfo 即可。此处为一个 Map,key 值您定义的话题分组列表字段名。getCommunityCustomInfo 方法已在上一段实现,示例代码如下: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,// ...其他资料));}
categoryName 建议使用格式:{"category":"分组1"}。addCategoryForTopic(String groupID, String categoryName) {TencentImSDKPlugin.v2TIMManager.getGroupManager().setTopicInfo(topicInfo: V2TimTopicInfo(customString: categoryName),groupID: groupID, // 话题所在的群组id);}
V2TIMCommunityListener (Details) 中增加了话题相关的回调方法,onCreateTopic,onDeleteTopic,onChangeTopicInfo,用来监听话题事件。 V2TIMCommunityListenerv2TIMCommunityListener= newV2TIMCommunityListener() {onCreateTopic(String groupID, String topicID) {// 监听话题创建通知}onDeleteTopic(String groupID, List<String> topicIDList) {// 监听话题删除通知}onChangeTopicInfo(String groupID, V2TIMTopicInfo topicInfo) {// 监听话题信息更新通知}};TencentImSDKPlugin.v2TIMManager.getCommunityManager().addCommunityListener(listener:v2TIMCommunityListener);
功能 | 接口 | 说明 |
发送消息 | 参数 groupID 填为话题 topicID | |
接收消息 | 消息中的 groupID 即为话题 topicID | |
标记消息已读 | 参数 groupID 填为话题 topicID | |
获取历史消息 | 参数 groupID 填为话题 topicID | |
撤回消息 | 参数 groupID 填为话题 topicID |
文档反馈