importMessages method

Future<void> importMessages(
  1. List<ChatMessage> messages
)

Imports messages to the local database.

Before importing, ensure that the sender or receiver of the message is the current user.

For each method call, we recommends to import less than 1,000 messages.

Param messages The message list.

Throws A description of the exception. See ChatError.

Implementation

Future<void> importMessages(List<ChatMessage> messages) async {
  List<Map> list = [];
  messages.forEach((element) {
    list.add(element.toJson());
  });
  Map req = {"messages": list};
  Map result =
      await ChatChannel.invokeMethod(ChatMethodKeys.importMessages, req);
  try {
    ChatError.hasErrorFromResult(result);
  } on ChatError catch (e) {
    throw e;
  }
}