importMessages method Null safety
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 {@link EMError}.
Implementation
Future<void> importMessages(List<EMMessage> messages) async {
List<Map> list = [];
messages.forEach((element) {
list.add(element.toJson());
});
Map req = {"messages": list};
Map result = await EMMethodChannel.ChatManager.invokeMethod(
ChatMethodKeys.importMessages, req);
try {
EMError.hasErrorFromResult(result);
} on EMError catch (e) {
throw e;
}
}