删除会话
删除指定会话
- 从会话列表中移除指定会话,不删除会话内的消息。
- 会话内再来一条消息,该会话之前的消息还存在,方便用户查看。
- 如果需要移除指定会话,并删除会话内的消息,请同时调用删除会话内消息接口。
方法
removeConversation(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
callback: IRCIMIWRemoveConversationCallback
): Promise<number>;
参数说明
参数名 | 参数类型 | 描述 |
---|---|---|
type | RCIMIWConversationType | 会话类型 |
targetId | string | 会话 ID |
channelId | string | 频道 ID,仅支持超级群使用,其他会话类型传 null 即可 |
callback | IRCIMIWRemoveConversationCallback | 移除会话事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 版本废弃该接口的其他回调方式。如果传入了 callback 参数,仅触发 callback 回调。 |
返回值
返回值 | 描述 |
---|---|
Promise<number> | 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考状态码文档。 |
代码示例
let callback = {
onConversationRemoved:(res) => {
//...
}};
let code = await engine.removeConversation(type, targetId, channelId, callback);
回调方法
- setOnConversationRemovedListener
setOnConversationRemovedListener(listener?: ({code, type, targetId, channelId}) => void): void;
参数说明
参数名 | 参数类型 | 描述 |
---|---|---|
code | number | 接口回调的状态码,0 代表成功,非 0 代表出现异常 |
type | RCIMIWConversationType | 会话类型 |
targetId | string | 会话 ID |
channelId | string | 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 |
代码示例
engine.setOnConversationRemovedListener((res) => {
//...
});
按会话类型删除
按指定的会话类型删除会话,并删除会话内的消息。
方法
removeConversations(
conversationTypes: Array<RCIMIWConversationType>,
channelId: string,
callback: IRCIMIWRemoveConversationsCallback
): Promise<number>;
参数说明
参数名 | 参数类型 | 描述 |
---|---|---|
conversationTypes | Array<RCIMIWConversationType> | 会话类型集合 |
channelId | string | 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 |
callback | IRCIMIWRemoveConversationsCallback | 移除会话列表事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 版本废弃该接口的其他回调方式。如果传入了 callback 参数,仅触发 callback 回调。 |