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
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)
}
})
Parameter | Type | Required | Description |
---|---|---|---|
channelId | String | No | Channel ID, defaults to retrieving the conversation list for all channels |
Retrieve Local Conversations by Pagination
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)
}
})
Parameter | Type | Required | Description |
---|---|---|---|
startTime | Number | Yes | Timestamp, accurate to milliseconds, 0 represents the current time |
count | Number | Yes | Number of items |
channelId | string | No | Channel ID, defaults to retrieving the conversation list for all channels |
topPriority | Boolean | No | Whether 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)
}
})
Parameter | Type | Required | Description |
---|---|---|---|
conversations | IConversationOption[] | Yes | An array of IConversationOption, supports up to 100 conversations per request. IConversationOption must provide the conversation type (ConversationType) and conversation ID (targetId ) |