insertMessage method

Future<void> insertMessage(
  1. EMMessage message
)

~english Inserts a message to a conversation in the local database and the SDK will automatically update the last message.

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 插入一条消息在 SDK 本地数据库,消息的 conversation ID 应该和会话的 conversation ID 一致,消息会根据消息里的时间戳被插入 SDK 本地数据库,并且更新会话的 latestMessage 等属性。

Param message 消息体实例。

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

Implementation

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