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 Name | Parameter Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. For other conversation types, pass null. |
timestamp | int | The timestamp of the last read message in the conversation |
callback | IRCIMIWSyncConversationReadStatusCallback | Event 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 Value | Description |
---|---|
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 Name | Parameter Type | Description |
---|---|---|
code | int | The status code of the callback. 0 indicates success, non-zero indicates an exception. |
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
channelId | String | Channel ID, only supported for ultra groups. For other conversation types, pass null. |
timestamp | int | The 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 Name | Parameter Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | String | Conversation ID |
timestamp | int | Timestamp |
Code Example
engine?.onConversationReadStatusSyncMessageReceived = (RCIMIWConversationType? type, String? targetId, int? timestamp) {
//...
};