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
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)
})
Parameter | Type | Description |
---|---|---|
messageId | number | Message ID |
receivedStatusInfo | IReceivedStatusInfo | Details of the message receipt status |
Supporting Single Status Setting
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)
})
Parameter | Type | Description |
---|---|---|
messageId | number | Message ID |
receivedStatus | ReceivedStatus | Message receipt status |
Setting the Sending Status of Messages
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)
})
Parameter | Type | Description |
---|---|---|
messageId | number | Message ID |
sentStatus | SentStatus | Message sending status |
Setting Message Status as Read by the Other Party via Timestamp
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)
})
Parameter | Type | Description |
---|---|---|
conversation | IConversationOption | Conversation |
timestamp | number | The sending time of the message; messages sent before this time will be set as read |