modifyMessage method
- required String messageId,
- required ChatTextMessageBody 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 ChatTextMessageBody.
Return The modified message.
Throws A description of the exception. See ChatError. ~end
~chinese 修改消息内容。
调用该方法修改消息内容后,本地和服务端的消息均会修改。
只能调用该方法修改单聊和群聊中的文本消息,不能修改聊天室消息。
Param messageId
消息实例 ID。
Param msgBody
文本消息体实例 ChatTextMessageBody。
Return 修改后的消息实例。
Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 ChatError。 ~end
Implementation
Future<ChatMessage> modifyMessage({
required String messageId,
required ChatTextMessageBody msgBody,
}) async {
Map map = {
'msgId': messageId,
'body': msgBody.toJson(),
};
Map result = await ChatChannel.invokeMethod(
ChatMethodKeys.modifyMessage,
map,
);
try {
ChatError.hasErrorFromResult(result);
return ChatMessage.fromJson(result[ChatMethodKeys.modifyMessage]);
} on ChatError catch (e) {
throw e;
}
}