返回
融云 Web SDK 删除历史消息后会话信息不会消失?怎么解决?
前端
2023-09-26 01:19:00
1. 时间戳删除历史消息后,会话列表仍包含已清空消息的会话
问题说明:
按照时间戳删除会话的历史消息后,刷新会话列表,发现会话列表中依然包含刚刚清空消息的会话。
解决方案:
在删除历史消息之前,您需要先退出会话,然后使用融云提供的 clearHistoryMessages
方法删除历史消息,再重新进入会话。
// 退出会话
RongIM.Conversation.exitConversation({conversationType: 1, targetId: 'userId'}, function(error) {
if (!error) {
// 删除历史消息
RongIM.Conversation.clearHistoryMessages({conversationType: 1, targetId: 'userId'}, function(error, result) {
if (!error) {
// 重新进入会话
RongIM.Conversation.joinConversation({conversationType: 1, targetId: 'userId'}, function(error) {
if (!error) {
// UI 渲染和跳转
// ...
}
});
}
});
}
});
2. 删除历史消息后,界面没有做删除/跳转的渲染
问题说明:
调用删除历史消息接口成功后,界面没有做删除/跳转的渲染,导致用户仍然可以看到刚刚清空消息的会话。
解决方案:
在调用删除历史消息接口成功后,您需要手动执行 UI 渲染和跳转操作。
// 删除历史消息成功后
RongIM.Conversation.clearHistoryMessages({conversationType: 1, targetId: 'userId'}, function(error, result) {
if (!error) {
// UI 渲染和跳转
// ...
}
});
希望本文对您有所帮助。如果您还有其他问题,欢迎随时与我们联系。