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 Name | Parameter Type | Description |
---|---|---|
conversationTypes | Array<RCIMIWConversationType> | Conversation type |
channelId | string | Channel ID, only supported for ultra groups, pass null for other conversation types |
startTime | number | Timestamp (in milliseconds), retrieves conversations before this timestamp, pass 0 to query the latest data |
count | number | Number of queries, count must be greater than 0 and less than or equal to 50 |
callback | IRCIMIWGetConversationsCallback | Callback for the interface result. |
Return Value
Return Value | Description |
---|---|
number | Status 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 Name | Parameter Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | string | Conversation ID |
channelId | string | Channel ID, only supported for ultra groups, pass null for other conversation types |
callback | IRCIMIWGetConversationCallback | Callback for the interface result. |
Return Value
Return Value | Description |
---|---|
number | Status 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.