清除消息未读状态
超级群业务可在多个客户端之间同步消息阅读状态。
同 步消息已读状态
调用同步已读状态接口会同时清除本地与服务端记录的消息的未读状态,同时服务端会将最新状态同步给同一用户账号的其他客户端。
- 如果指定了频道 ID(channelId),则标记该频道所有消息为全部已读,并同步其他客户端。
- 如果频道 ID 为空,则标记该超级群会话下所有不属于任何频道的消息为全部已读,并同步其他客户端。
提示
超级群暂不支持按时间戳同步已读状态。调用 syncUltraGroupReadStatus
会按指定参数的要求标记全部消息为已读。时间戳参数(timestamp)未使用,可传入任意数字。
方法
syncUltraGroupReadStatus(
targetId: string,
channelId: string,
timestamp: number,
callback: IRCIMIWSyncUltraGroupReadStatusCallback
): Promise<number>;
参数说明
参数名 | 参数类型 | 描述 |
---|---|---|
targetId | string | 会话 ID |
channelId | string | 频道 ID,仅支持超级群使用。 |
timestamp | number | 已读时间 |
callback | IRCIMIWSyncUltraGroupReadStatusCallback | 接口调用结果回调。 |
返回值
返回值 | 描述 |
---|---|
number | 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 |
代码示例
const callback = {
onUltraGroupReadStatusSynced: (code: number) => {
//...
},
};
let code = await engine.syncUltraGroupReadStatus(targetId, channelId, timestamp, callback);
监听其他端同步的消息未读状态
当接收到其他端同步的未读状态时,会回调此方法
方法
setOnConversationReadStatusSyncMessageReceivedListener(listener?: (type: RCIMIWConversationType, targetId: string, timestamp: number) => void): void;
参数说明
参数名 | 参数类型 | 描述 |
---|---|---|
type | RCIMIWConversationType | 会话类型 |
targetId | string | 会话 ID |
timestamp | number | 时间戳 |
代码示例
engine?.setOnConversationReadStatusSyncMessageReceivedListener(
(type: RCIMIWConversationType, targetId: string, timestamp: number) => {
//...
},
);