deleteRemoteConversation method

Future<void> deleteRemoteConversation(
  1. String conversationId, {
  2. EMConversationType conversationType = EMConversationType.Chat,
  3. bool isDeleteMessage = true,
})

~english Deletes the specified conversation and the related historical messages from the server.

Param conversationId The conversation ID.

Param conversationType The conversation type. See EMConversationType.

Param isDeleteMessage Whether to delete the chat history when deleting the conversation.

  • true: (default) Yes.
  • false: No.

Throws A description of the exception. See EMError. ~end

~chinese 删除服务端的指定 ID 的会话和聊天记录。

Param conversationId 会话 ID。

Param conversationType 会话类型,详见 EMConversationType

Param isDeleteMessage 删除会话时是否同时删除历史消息记录。

  • (默认)true:是;
  • false:否。

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 ~end

Implementation

Future<void> deleteRemoteConversation(
  String conversationId, {
  EMConversationType conversationType = EMConversationType.Chat,
  bool isDeleteMessage = true,
}) async {
  Map req = {};
  req["conversationId"] = conversationId;
  if (conversationType == EMConversationType.Chat) {
    req["conversationType"] = 0;
  } else if (conversationType == EMConversationType.GroupChat) {
    req["conversationType"] = 1;
  } else {
    req["conversationType"] = 2;
  }
  req["isDeleteRemoteMessage"] = isDeleteMessage;

  Map data = await ChatChannel.invokeMethod(
      ChatMethodKeys.deleteRemoteConversation, req);
  try {
    EMError.hasErrorFromResult(data);
  } on EMError catch (e) {
    throw e;
  }
}