全部文档

更新时间: 2021-03-08

# 功能描述

聊天消息保存在云端,用户进入聊天室后,可以查看聊天室中以前的消息,历史消息默认保存 2 个月。必须在 IM 商用版 - 增值服务 中开通 聊天室消息云存储 (opens new window)功能。

# 参数说明

输入参数说明

参数 类型 必填 说明
targetId NSString 聊天室 ID
recordTime int 起始的消息发送时间戳,毫秒
count int 需要获取的消息数量, 0 < count <= 200
order RCTimestampOrder 拉取顺序,RC_Timestamp_Desc:倒序,RC_Timestamp_ASC:正序

回调参数说明

回调参数 回调类型 说明
msgList List<Message> 获取到的历史消息数组
syncTime int 下次拉取消息的时间戳
code int 错误码,0 代表操作成功
# 代码示例
void _getChatRoomHistoryMessage() {
  RongIMClient.getRemoteChatroomHistoryMessages(
      targetId, 0, 20, RCTimestampOrder.RC_Timestamp_Desc,
      (List/*<Message>*/ msgList, int syncTime, int code) {
    DialogUtil.showAlertDiaLog(
        context,
        "获取聊天室历史消息: code: " +
            CodeUtil.codeString(code) +
            ", msgListCount: ${msgList.length} 条消息\n" +
            ", msgList: $msgList" +
            ", syncTime: $syncTime");
  });
}
已复制
1
2
3
4
5
6
7
8
9
10
11
12
13

文档是否解决您的问题 ?

如果遇到产品相关问题,您可 提交工单 寻求帮助