TencentImSDKPlugin.v2TIMManager.getGroupManager()
core class.TencentImSDKPlugin.v2TIMManager.getMessageManager()
core class.V2TIMGroupInfo
object (Details) and set groupType
to Community
and isSupportTopic
to true
/YES
.createGroup
API (Details) to create a community.// Create a topic-enabled communitygroupManager.createGroup(groupType: "Community", groupName: "Community",isSupportTopic: true);
// Getting the list of community groups joinedconst groupList = await groupManager.getJoinedCommunityList();
Category | Feature | API |
Community group management | ||
| ||
| ||
| ||
| ||
Community group member management | ||
| ||
| ||
|
V2TIMTopicInfo
(Details) object.createTopicInCommunity
API (Details) to create a topic.// Create a topicgroupManager.createTopicInCommunity("groupID", {topicName: "topic",});
// Delete a topicgroupManager.deleteTopicFromCommunity("groupID", ["topicID"]);
V2TIMTopicInfo
object (Details) and set the fields to be modified.setTopicInfo
API (Details) to modify the information of a topic.// Modify topic informationgroupManager.setTopicInfo({topicName: "topicName",});
topicIDList
is empty, 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", ["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 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 categoryList
.getCommunityCategoryList(String groupID)
method. Sample code:const getCommunityCategoryList = async (groupID) => {const customInfo = await getCommunityCustomInfo(groupID);if (customInfo != null) {const categoryListString = customInfo["categoryList"];if (categoryListString != null && categoryListString !== "") {return JSON.parse(categoryListString);}}};const getCommunityCustomInfo = async (groupID) => {const groupIDList = [groupID];const res = await TencentImSDKPlugin.v2TIMManager.getGroupManager().getGroupsInfo(groupIDList);if (res.code != 0) {const groupInfo = res.data[0];if (groupInfo != null) {const 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:const setCommunityCategoryList = async (groupID,groupType,newCategoryList) => {const customInfo = await getCommunityCustomInfo(groupID);customInfo["categoryList"] = JSON.parse(newCategoryList);TencentImSDKPlugin.v2TIMManager.getGroupManager().setGroupInfo({customInfo: customInfo,groupID: groupID,groupType: groupType,// ...Other profiles});};
const addCategoryForTopic = (groupID, categoryName) => {TencentImSDKPlugin.v2TIMManager.getGroupManager().setTopicInfo({customString: categoryName,});};
V2TIMGroupListener
(Details), topic callback methods such as onTopicCreated
, onTopicDeleted
, and onTopicInfoChanged
are added to listen for topic events.const v2TIMGroupListener = {onTopicCreated: (groupID, topicID) => {// Listen for topic creation notifications},onTopicDeleted: (groupID, topicIDList) => {// Listen for topic deletion notifications},onTopicInfoChanged: (groupID, topicInfo) => {// Listen for topic information update notifications},};V2TIMManager.getInstance().addGroupListener(v2TIMGroupListener);
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 | markGroupMessageAsRead (TS | Set `groupID` to the topic ID. |
Gets historical messages | getGroupHistoryMessageList (TS | Set `groupID` to the topic ID. |
Recalls a message | Set `groupID` to the topic ID. |
Was this page helpful?