fetchLatestMessageWithChatThreads method
Get the latest news of the specified Chat Thread list from the server.
Param chatThreadIds
Chat Thread id list. The list length is not greater than 20.
Return returns a Map collection, the key is the chat thread ID, and the value is the latest message object of the chat thread.
Throws A description of the exception. See ChatError.
Implementation
Future<Map<String, ChatMessage>> fetchLatestMessageWithChatThreads({
required List<String> chatThreadIds,
}) async {
Map req = {
"threadIds": chatThreadIds,
};
Map result = await _channel.invokeMethod(
ChatMethodKeys.fetchLastMessageWithChatThreads,
req,
);
try {
ChatError.hasErrorFromResult(result);
Map? map = result[ChatMethodKeys.fetchLastMessageWithChatThreads];
Map<String, ChatMessage> ret = {};
if (map == null) {
return ret;
}
for (var key in map.keys) {
Map<String, Object> msgMap = map[key].cast<Map<String, Object>>();
ret[key] = ChatMessage.fromJson(msgMap);
}
return ret;
} on ChatError catch (e) {
throw e;
}
}