获取聊天室历史消息
开通服务
使用 getChatroomHistoryMessages 要求开通 聊天室消息云端存储服务。使用前请确认已开通服务。开通后聊天室历史消息保存在云端,默认保存 2 个月。
获取聊天室历史消息
获取保存在服务端的聊天室历史消息。
const chatRoomId = "聊天室 ID";
const timestamp = 0;
const count = 10
const order = 1
RongIMLib.getChatroomHistoryMessages(chatRoomId, {
timestamp: timestamp,
count: count,
order: order
}).then(res => {
// 获取聊天室历史信息成功
if (res.code === 0){
console.log(res.code, res.data)
} else {
console.log(res.code, res.msg)
}
}).catch(error => {
console.log(error)
})
参数 | 类型 | 说明 |
---|---|---|
targetId | string |