51010
错误,不再使用的分组请及时删除。chat.createConversationGroup(options);
参数 | 类型 | 说明 |
conversationIDList | String | 会话 ID 列表 |
groupName | String | 分组名,长度最大支持32字节 |
Promise
let promise = chat.createConversationGroup({conversationIDList: ['GROUPtest', 'C2Cexample'],groupName: 'Suppliers',});promise.then(function(imResponse) {// 创建会话分组成功const { successConversationIDList, failureConversationIDList } = imResponse.data;// successConversationIDList - 成功的会话 ID 列表// 获取会话列表const conversationList = chat.getConversationList(successConversationIDList);// failureConversationIDList - 失败的会话 ID 列表failureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError) {console.warn('createConversationGroup error:', imError);});
51009
错误。chat.deleteConversationGroup(groupName);
参数 | 类型 | 说明 |
groupName | String | 分组名,长度最大支持32字节 |
Promise
let promise = chat.deleteConversationGroup('Suppliers');promise.then(function() {// 删除成功}).catch(function(imError) {console.warn('deleteConversationGroup error:', imError);});
chat.renameConversationGroup(options);
参数 | 类型 | 说明 |
oldName | String | 旧的分组名 |
newName | String | 新的分组名,长度最大支持32字节 |
Promise
let promise = chat.renameConversationGroup({oldName: 'Suppliers_old',newName: 'Suppliers_new'});promise.then(function(imResponse) {// 重命名成功}).catch(function(imError) {console.warn('renameConversationGroup error:', imError);});
chat.getConversationGroupList();
Promise
let promise = chat.getConversationGroupList();promise.then(function(imResponse) {const groupNameList = imResponse.data; // 会话分组名列表});
// 获取指定会话分组下的所有会话let promise = chat.getConversationList({ groupName: 'Suppliers' });promise.then(function(imResponse) {const conversationList = imResponse.data.conversationList; // 会话列表});
chat.addConversationsToGroup(options);
参数 | 类型 | 说明 |
conversationIDList | String | 会话 ID 列表 |
groupName | String | 分组名,长度最大支持32字节 |
Promise
let promise = chat.addConversationsToGroup({conversationIDList: ['GROUPtest', 'C2Cexample'],,groupName: 'Suppliers_new',});promise.then(function(imResponse) {// 添加会话到分组成功const { successConversationIDList, failureConversationIDList } = imResponse.data;// successConversationIDList - 成功的会话 ID 列表// 获取会话列表const conversationList = chat.getConversationList(successConversationIDList);// failureConversationIDList - 失败的会话 ID 列表failureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError) {console.warn('addConversationsToGroup error:', imError);});
chat.deleteConversationsFromGroup(options);
参数 | 类型 | 说明 |
conversationIDList | String | 会话 ID 列表 |
groupName | String | 分组名,长度最大支持32字节 |
Promise
let promise = chat.deleteConversationsFromGroup({conversationIDList: ['GROUPtest', 'C2Cexample'],,groupName: 'Suppliers_new',});promise.then(function(imResponse) {// 从分组删除会话成功const { successConversationIDList, failureConversationIDList } = imResponse.data;// successConversationIDList - 成功的会话 ID 列表// 获取会话列表const conversationList = chat.getConversationList(successConversationIDList);// failureConversationIDList - 失败的会话 ID 列表failureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError) {console.warn('deleteConversationsFromGroup error:', imError);});
let onConversationGroupListUpdated = function(event) {console.log(event.data); // 全量的会话分组名列表}chat.on(TencentCloudChat.EVENT.CONVERSATION_GROUP_LIST_UPDATED, onConversationGroupListUpdated);
let onConversationInGroupUpdated = function(event) {const { groupName, conversationList } = event.data;// groupName - 会话分组名// conversationList - 分组内的会话列表}chat.on(TencentCloudChat.EVENT.CONVERSATION_IN_GROUP_UPDATED, onConversationInGroupUpdated);
本页内容是否解决了您的问题?