Skip to main content

Get Conversation (Electron)

This document is only applicable to the Electron solution and is limited to use with the Electron modules (@rongcloud/electron and @rongcloud/electron-renderer).

This document describes how to retrieve conversations locally from the client.

Retrieve All Local Conversations

tip

This API is supported starting from SDK version 5.4.0. Note: Retrieving local conversations must be performed after calling RongIMLib.connect() and successfully establishing a connection.

Call electronExtension.getAllConversationList to retrieve all local conversations.

RongIMLib.electronExtension.getAllConversationList().then(res => {
if (res.code === 0) {
console.log(res.code, res.data)
} else {
console.log(res.code, res.msg)
}
})
ParameterTypeRequiredDescription
channelIdStringNoChannel ID, defaults to retrieving the conversation list for all channels

Retrieve Local Conversations by Pagination

tip

This API is supported starting from SDK version 5.4.0. Note: Retrieving local conversations must be performed after calling RongIMLib.connect() and successfully establishing a connection.

Call electronExtension.getConversationList to retrieve local conversations by pagination.

const startTime = 0
const count = 10

RongIMLib.electronExtension.getConversationList(startTime, count).then(res => {
if (res.code === 0) {
console.log(res.code, res.data)
} else {
console.log(res.code, res.msg)
}
})
ParameterTypeRequiredDescription
startTimeNumberYesTimestamp, accurate to milliseconds, 0 represents the current time
countNumberYesNumber of items
channelIdstringNoChannel ID, defaults to retrieving the conversation list for all channels
topPriorityBooleanNoWhether to sort the conversation list by pinned status, default is false

Batch Retrieve Conversation Information

Note

This API is supported starting from SDK version 5.9.9. Note: Retrieving local conversations must be performed after calling RongIMLib.connect() and successfully establishing a connection.

// Supports up to 100 conversations
const conversations = [{ targetId:"user1", conversationType:1 }];

RongIMLib.electronExtension.getConversations(conversations).then(res => {
if (res.code === 0) {
console.log(res.code, res.data)
} else {
console.log(res.code, res.msg)
}
})
ParameterTypeRequiredDescription
conversationsIConversationOption[]YesAn array of IConversationOption, supports up to 100 conversations per request. IConversationOption must provide the conversation type (ConversationType) and conversation ID (targetId)