importMessages method

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

Imports messages to the local database.

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

It is recommended that you import at most 1,000 messages each time.

Param messages The message list.

Throws A description of the exception. See ChatError.

Implementation

Future<void> importMessages(List<ChatMessage> messages) async {
  try {
    List<Map> list = [];
    for (var element in messages) {
      list.add(element.toJson());
    }
    Map req = {"messages": list};
    Map result = await platform_interface.Client.instance.chatManager
        .callNativeMethod(ChatMethodKeys.importMessages, req);
    ChatError.hasErrorFromResult(result);
  } catch (e) {
    rethrow;
  }
}