appendMessage method

Future<void> appendMessage(
  1. EMMessage message
)

~english Inserts a message to the end of a conversation in the local database.

Make sure you set the conversation ID as that of the conversation where you want to insert the message.

Param message The message instance.

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

~chinese 插入一条消息到会话尾部。

@note 请确保消息的 conversation ID 与要插入的会话的 conversationId 一致,消息会被插入 SDK 本地数据库,并且更新会话的 latestMessage 等属性。 Param message 消息体实例。

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

Implementation

Future<void> appendMessage(EMMessage message) async {
  Map req = this._toJson();
  req['msg'] = message.toJson();
  Map result = await _emConversationChannel.invokeMethod(
      ChatMethodKeys.appendMessage, req);
  try {
    EMError.hasErrorFromResult(result);
  } on EMError catch (e) {
    throw e;
  }
}