Skip to main content

Set Message Status (Electron)

The message status feature is exclusively available for use with the Electron modules (@rongcloud/electron and @rongcloud/electron-renderer).

This document is applicable only to the Electron solution and describes how to maintain the receipt, sending, and read status of messages in the client's local database.

Setting the Receipt Status of Messages

Supporting Multiple Status Settings Simultaneously

tip

This interface is supported starting from SDK version 5.9.3.

Call electronExtension.setMessageReceivedStatusInfo to set the receipt status of messages sent by the other party (supporting multiple status settings simultaneously).

const messageId = 1 // Use the messageId field from the message
const receivedStatusInfo = {
isRead: true,
isListened: true,
isDownload: false,
isRetrieved: false,
}
RongIMLib.electronExtension.setMessageReceivedStatusInfo(messageId, receivedStatusInfo).then(res => {
console.log(res.code)
})

ParameterTypeDescription
messageIdnumberMessage ID
receivedStatusInfoIReceivedStatusInfoDetails of the message receipt status

Supporting Single Status Setting

tip

This interface is supported from SDK version 5.4.0 and deprecated in version 5.9.3. If the IMLib SDK version is ≧ 5.9.3, it is recommended to use the setMessageReceivedStatusInfo interface instead.

Call electronExtension.setMessageReceivedStatus to set the receipt status of messages sent by the other party.

const messageId = 1 // Use the messageId field from the message
RongIMLib.electronExtension.setMessageReceivedStatus(messageId, RongIMLib.ReceivedStatus.READ).then(res => {
console.log(res.code)
})

ParameterTypeDescription
messageIdnumberMessage ID
receivedStatusReceivedStatusMessage receipt status

Setting the Sending Status of Messages

tip

This interface is supported starting from SDK version 5.4.0.

Call electronExtension.setMessageSentStatus to set the sending status of messages you have sent.

const messageId = 1 // Use the messageId field from the message
RongIMLib.electronExtension.setMessageSentStatus(messageId, RongIMLib.SentStatus.SENT).then(res => {
console.log(res.code)
})

ParameterTypeDescription
messageIdnumberMessage ID
sentStatusSentStatusMessage sending status

Setting Message Status as Read by the Other Party via Timestamp

tip

This interface is supported starting from SDK version 5.4.0.

Call electronExtension.setMessageStatusToRead to set messages sent before the specified time as read by the other party, with the status value as SentStatus.READ.

const conversation = {
conversationType: RongIMLib.ConversationType.PRIVATE,
targetId: "<Target User ID>",
channelId: ""
}
const timestamp = 1632728573423
RongIMLib.electronExtension.setMessageStatusToRead(conversation, timestamp).then(res => {
console.log(res.code)
})

ParameterTypeDescription
conversationIConversationOptionConversation
timestampnumberThe sending time of the message; messages sent before this time will be set as read