多端阅读消息数同步

参数说明

参数 类型 说明
type Conversation.ConversationType 会话类型
type Message.ReceivedStatus 目标会话 ID
timestamp long 该会话中已读的最后一条消息的发送时间戳
RongIMClient.OperationCallback() RongIMClient.OperationCallback() 回调

示例代码:

RongIMClient.getInstance().syncConversationReadStatus(type, targetId, timestamp, new RongIMClient.OperationCallback() {
    @Override
    public void onSuccess() {
    }

    @Override
    public void onError(RongIMClient.ErrorCode errorCode) {
    }
});

另外,请设置同步阅读状态监听器。

/**
 * 同步阅读状态监听
 * 多端登录,收到其它端清除某一会话未读数通知的时候,回调 onSyncMessageReadStatus
 */
public interface SyncConversationReadStatusListener {
    void onSyncConversationReadStatus(Conversation.ConversationType type, String targetId);
}
RongIMClient.getInstance().setSyncConversationReadStatusListener(new RongIMClient.SyncConversationReadStatusListener() {
    @Override
    public void onSyncConversationReadStatus(Conversation.ConversationType type, String targetId) {
        //重新获取会话的未读数,并且显示到界面上
    }
});