Skip to main content

Get Conversations

The client SDK generates corresponding conversations in the local database based on sent and received messages. You can retrieve the conversation list generated by the SDK from the local database.

Get Conversation List

Use the following interface to paginate and retrieve the conversation list generated by the SDK in the local database. The retrieved conversation list is sorted in reverse chronological order, with pinned conversations appearing first.

Method


getConversations(
conversationTypes: Array<RCIMIWConversationType>,
channelId: string,
startTime: number,
count: number,
callback: IRCIMIWGetConversationsCallback
): Promise<number>;

Parameter Description

Parameter NameParameter TypeDescription
conversationTypesArray<RCIMIWConversationType>Conversation type
channelIdstringChannel ID, only supported for ultra groups, pass null for other conversation types
startTimenumberTimestamp (in milliseconds), retrieves conversations before this timestamp, pass 0 to query the latest data
countnumberNumber of queries, count must be greater than 0 and less than or equal to 50
callbackIRCIMIWGetConversationsCallbackCallback for the interface result.

Return Value

Return ValueDescription
numberStatus code of the current interface operation. 0 indicates a successful call, specific results need to be implemented in the interface callback, non-0 indicates the current interface call operation failed, the interface callback will not be triggered, refer to the error code for detailed errors

Code Example


const callback = {
onSuccess: (t: Array<RCIMIWConversation>) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.getConversations(conversationTypes, channelId, startTime, count, callback);

Get a Specific Conversation

Retrieve detailed information about a specific conversation.

Method


getConversation(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
callback: IRCIMIWGetConversationCallback
): Promise<number>;

Parameter Description

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringChannel ID, only supported for ultra groups, pass null for other conversation types
callbackIRCIMIWGetConversationCallbackCallback for the interface result.

Return Value

Return ValueDescription
numberStatus code of the current interface operation. 0 indicates a successful call, specific results need to be implemented in the interface callback, non-0 indicates the current interface call operation failed, the interface callback will not be triggered, refer to the error code for detailed errors

Code Example


const callback = {
onSuccess: (t: RCIMIWConversation) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.getConversation(type, targetId, channelId, callback);

FAQ

Q1: When a user uninstalls and reinstalls, they find the conversation list empty or some conversations missing.

A1: Since the conversation list is retrieved from the local database, which is stored internally by the SDK, uninstalling the app deletes the local database, resulting in an empty conversation list upon reinstallation. The presence of some conversations is due to the offline message compensation feature being enabled. Specifically, this involves purchasing the Multi-Device Message Synchronization feature in the backend, which by default includes offline message compensation for the current day (starting from 0 o'clock). Therefore, when a user logs in on a new device, the offline message compensation feature is triggered, retrieving some conversations and creating the illusion of missing conversations. If you need offline message compensation for more days, you can submit a ticket to modify this, with a maximum support of 7 days. Setting this for too long may cause excessive message compensation for a single user with a large message volume, potentially putting pressure on the client-side processing.