RongIMLib View Markdown
    Preparing search index...

    Function sendReadReceiptMessage

    • 发送单聊已读回执

      Parameters

      • targetId: string

        目标 ID

      • messageUId: string

        消息唯一标识,可在 Message 中获取

      • timestamp: number

        消息的发送时间,可通过 Message 中 sendTime 获取

      • OptionalchannelId: string

      Returns Promise<RCResult<void>>

      发送单聊已读回执,用于标记已读消息 实现已读功能步骤:

      1. 在用户查看了某单聊会话的未读消息后,调用 sendReadReceiptMessage 发送已读回执。
      2. 通过 addEventListener 设置消息回执监听器。
      3. SDK 在收到消息已读回执时派发 READ_RECEIPT_RECEIVED 事件。
      • 注意:
      1. 在 Web 平台,SDK 不会记录每个会话和消息的已读状态,您需要在 LocalStorage 中记录每个会话的已读时间。在渲染消息列表时,根据 LocalStorage 中时间判断消息是否已读,更新对应的消息界面。
      2. 在 Electron 平台,收到 READ_RECEIPT_RECEIVED 通知时,您需要调用 electronExtension.setMessageStatusToRead 方法更新消息已读状态,并更新对应的消息界面。
      3. 调用 sendReadReceiptMessage 接口不会清除未读数,需单独调用清除未读数接口 clearMessagesUnreadStatus。

      单聊消息回执示例:

      const targetId = 'targetId';
      const messageUId = 'BS4O-QEBR-VJM6-9GPP';
      const timestamp = 1632728573423;

      const readReceiptRes = await RongIMLib.sendReadReceiptMessage(targetId, messageUId, timestamp);
      console.info('单聊消息回执:', readReceiptRes)