删除会话
App 用户可能需要从会话列表中删除一个会话或多个会话,可以通过 SDK 删除会话功能实现。客户端的会话列表是根据本地消息生成的,删除会话操作指的是删除本地会话。
删除指定批量会话
调用 removeConversation 可实现软删除的效果。该接口实际不会删除会话内的消息,仅将该会话项目从 SDK 的会话列表中移除。成功删除会话后,App 可以刷新 UI,不再向用户展示该会话项目。
let conIdList = new List<ConversationIdentifier>();
let conId1 = new ConversationIdentifier();
conId1.conversationType = ConversationType.Private;
conId1.targetId = "会话 id";
conIdList.add(conId1)
let conId2 = new ConversationIdentifier();
conId2.conversationType = ConversationType.Private;
conId2.targetId = "会话 id";
conIdList.add(conId2)
IMEngine.getInstance().removeConversations(conIdList)
.then(result => {
if (EngineError.Success !== result.code) {
// 删除会话失败
return;
}
});
参数 | 类型 | 说明 |
---|---|---|
conIdList | List<ConversationIdentifier> | 会话标识数组 |
如果会话内再来一条消息,该会话会重新出现在会话列表中,App 用户可查看会话内的历史消息和最新消息。
SDK 未提供同时删除指定会话项目和会话历史消息的接口。如果需要同时删除会话内的消息,您可以在删除指定会话时同时调用删除消息的接口。详见删除消息。