跳到主要内容

多端同步阅读状态

同步消息未读状态

多端登录时,通知其它终端同步某个会话的消息未读状态。

方法

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

参数说明

参数名参数类型描述
typeRCIMIWConversationType会话类型
targetIdString会话 ID
channelIdString频道 ID,仅支持超级群使用,其他会话类型传 null 即可。
timestampint会话中已读的最后一条消息的发送时间戳
callbackIRCIMIWSyncConversationReadStatusCallback事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 版本废弃该接口的其他回调方式。如果传入了 callback 参数,仅触发 callback 回调。

返回值

返回值描述
Future<int>当次接口操作的状态码。0 代表接口调用成功,具体业务结果需要从接口回调获取,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码

代码示例

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

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

监听同步消息未读状态

当用户调用syncConversationReadStatus同步消息未读状态时,远端用户会收到该回调

方法

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

参数说明

参数名参数类型描述
typeRCIMIWConversationType会话类型
targetIdString会话 ID
timestampint时间戳

代码示例

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