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

Future<int> syncConversationReadStatus(RCIMIWConversationType type, String targetId, String? channelId, int timestamp, {IRCIMIWSyncConversationReadStatusCallback? callback});

Parameter Description

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. For other conversation types, pass null.
timestampintThe timestamp of the last read message in the conversation
callbackIRCIMIWSyncConversationReadStatusCallbackEvent callback. SDK supports callback from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If a callback is provided, only the callback will be triggered.

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success. The specific result needs to be implemented via the callback. Non-zero indicates the operation failed, and the callback will not be triggered. Refer to the error code for details.

Code Example

IRCIMIWSyncConversationReadStatusCallback? callback = IRCIMIWSyncConversationReadStatusCallback(onConversationReadStatusSynced: (int? code) {
//...
});

int? ret = await engine?.syncConversationReadStatus(type, targetId, channelId, timestamp, callback:callback);

Callback Method

  • onConversationReadStatusSynced
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, int? timestamp)? onConversationReadStatusSynced;

Parameter Description

Parameter NameParameter TypeDescription
codeintThe status code of the callback. 0 indicates success, non-zero indicates an exception.
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
channelIdStringChannel ID, only supported for ultra groups. For other conversation types, pass null.
timestampintThe timestamp of the last read message in the conversation

Code Example

engine?.onConversationReadStatusSynced = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, int? timestamp) {
//...
};

Listen for Synchronized Unread Message Status

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

Method

Function(RCIMIWConversationType? type, String? targetId, int? timestamp)? onConversationReadStatusSyncMessageReceived;

Parameter Description

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdStringConversation ID
timestampintTimestamp

Code Example

engine?.onConversationReadStatusSyncMessageReceived = (RCIMIWConversationType? type, String? targetId, int? timestamp) {
//...
};