please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Web/
Conversation/
SDK
  • Install Chat SDK
  • Initialize Chat SDK
  • Login and Logout
  • Client APIs
  • Changelog
  • Message
    • Overview
    • Send a Message
    • Receive a Message
    • Historical Message
    • Forward Messages
    • Modify a Message
    • Delete Messages
    • Clear History Message
    • Recall a Message
    • Send an Online Message
    • Message Read Receipt
    • Query Messages
    • Targeted Group Message
    • Do not Notify
    • Key-Value Extensions
    • Translation
  • Conversation
    • Overview
    • Conversation List
    • Get Conversations
    • Unread Count
    • Pin Conversations
    • Delete Conversations
    • Mark
    • Conversation Group
  • Group
    • Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
    • Group Counter
  • Community Topic
    • Community Management
  • User Profile and Relationship Chain
    • User Profile
    • User Status
    • Friend Management
    • Friend Group
    • Block List
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

Conversation List

Feature Description

With conversation lists, users can easily locate target conversations after they log in to the application.
The conversation list feature includes getting the conversation list and listening for conversation list update events. The core data structure is Conversation.

Getting the Conversation List

Call the getConversationList API on the access side to get the conversation list.
API
chat.getConversationList(options);
The options is as described below:
Name
Type
Description
options
undefined | Array | Object
If options is undefined, the SDK will return all the conversations.
if options is of the Array type, it shall not be empty, the SDK will return specified conversations.
if options is of the Object type, as {type, markType, groupName}, the SDK will return filtered conversations.
Returned Value
Promise
Sample
// Get the full conversation list
let promise = chat.getConversationList();
promise.then(function(imResponse) {
// This full conversation list will overwrite the original conversation list.
const conversationList = imResponse.data.conversationList;
// Whether synchronizing the conversation list from the cloud is completed
const isSyncCompleted = imResponse.data.isSyncCompleted;
}).catch(function(imError){
console.warn('getConversationList error:', imError); // Error information
});
// Get the list of specified conversations
let promise = chat.getConversationList([conversationID1, conversationID2]);
promise.then(function(imResponse) {
// List of specified conversations that already exist in the cache
const conversationList = imResponse.data.conversationList;
}).catch(function(imError){
console.warn('getConversationList error:', imError); // Error information
});
// Get all group conversations
let promise = chat.getConversationList({ type: TencentCloudChat.TYPES.CONV_GROUP });
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList; // Conversation list
});
// Obtain all conversations that are marked as "favorite"
let promise = chat.getConversationList({ markType: TencentCloudChat.TYPES.CONV_MARK_TYPE_STAR });
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList; // Conversation list
});
// Obtain all conversations in a specified conversation group
let promise = chat.getConversationList({ groupName: 'Suppliers' });
promise.then(function(imResponse) {
const conversationList = imResponse.data.conversationList; // Conversation list
});

Listening for Conversation List Update Events

Listen for TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED events on the access side to get conversation list update notifications.
Sample
let onConversationListUpdated = function(event) {
console.log(event.data); // Array that stores Conversation instances
};
chat.on(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED, onConversationListUpdated);