modifyMessage method

Future<EMMessage> modifyMessage({
  1. required String messageId,
  2. required EMTextMessageBody msgBody,
})

~english Modifies a message.

After this method is called to modify a message, both the local message and the message on the server are modified.

This method can only modify a text message in one-to-one chats or group chats, but not in chat rooms.

Param messageId The ID of the message to modify.

Param msgBody The modified message body EMTextMessageBody.

Return The modified message.

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

~chinese 修改消息内容。

调用该方法修改消息内容后,本地和服务端的消息均会修改。

只能调用该方法修改单聊和群聊中的文本消息,不能修改聊天室消息。

Param messageId 消息实例 ID。

Param msgBody 文本消息体实例 EMTextMessageBody

Return 修改后的消息实例。

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

Implementation

Future<EMMessage> modifyMessage({
  required String messageId,
  required EMTextMessageBody msgBody,
}) async {
  Map map = {
    'msgId': messageId,
    'body': msgBody.toJson(),
  };

  Map result = await ChatChannel.invokeMethod(
    ChatMethodKeys.modifyMessage,
    map,
  );
  try {
    EMError.hasErrorFromResult(result);
    return EMMessage.fromJson(result[ChatMethodKeys.modifyMessage]);
  } on EMError catch (e) {
    throw e;
  }
}