Skip to main content

Multi-Device Synchronization of Read Status

Synchronize Unread Message Status​

When logging in from multiple devices, notify other terminals to synchronize the unread message status of a specific conversation.

Method​


syncConversationReadStatus(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
timestamp: number,
callback: IRCIMIWSyncConversationReadStatusCallback
): Promise<number>;

Parameter Description​

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringChannel ID, only supported for ultra groups. For other conversation types, pass null.
timestampnumberThe timestamp of the last read message in the conversation
callbackIRCIMIWSyncConversationReadStatusCallbackCallback for the result of the interface call.

Return Value​

Return ValueDescription
numberThe status code of the current interface operation. 0 indicates a successful call. The specific result needs to be implemented in the interface callback. Non-zero indicates that the current interface call operation failed, and the interface callback will not be triggered. For detailed errors, refer to the error codes.

Code Example​


const callback = {
onConversationReadStatusSynced: (code: number) => {
//...
},
};
let code = await engine.syncConversationReadStatus(type, targetId, channelId, timestamp, callback);

Listen for Synchronized Unread Message Status​

When a user calls syncConversationReadStatus to synchronize the unread message status, the remote user will receive this callback.

Method​

setOnConversationReadStatusSyncMessageReceivedListener(listener?: (type: RCIMIWConversationType, targetId: string, timestamp: number) => void): void;

Parameter Description​

ParameterTypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
timestampnumberTimestamp

Code Example​


engine?.setOnConversationReadStatusSyncMessageReceivedListener(
(type: RCIMIWConversationType, targetId: string, timestamp: number) => {
//...
}
);