功能描述
用户在登录 App 后,可以展示最近会话列表,方便找到目标会话。
获取会话列表
获取全量的会话列表
let promise = chat.getConversationList();
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList;
const isSyncCompleted = imResponse.data.isSyncCompleted;
}).catch(function(imError) {
console.warn('getConversationList error:', imError);
});
获取指定的会话列表
let promise = chat.getConversationList([
conversationID1,
conversationID2
]);
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList;
}).catch(function(imError) {
console.warn('getConversationList error:', imError);
});
获取所有的群会话
let promise = chat.getConversationList({
type: TencentCloudChat.TYPES.CONV_GROUP
});
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList;
});
获取所有的“标星”会话
let promise = chat.getConversationList({
markType: TencentCloudChat.TYPES.CONV_MARK_TYPE_STAR
});
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList;
});
获取指定会话分组下的所有会话
let promise = chat.getConversationList({ groupName: 'Suppliers' });
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList;
});
监听会话列表更新事件
示例
let onConversationListUpdated = function(event) {
console.log(event.data);
};
chat.on(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED, onConversationListUpdated);
本页内容是否解决了您的问题?