fetchHistoryMessages method

Future<EMCursorResult<EMMessage?>> fetchHistoryMessages(
  1. String conversationId, {
  2. EMConversationType type = EMConversationType.Chat,
  3. int pageSize = 20,
  4. String startMsgId = '',
})

在会话conversationId中提取历史消息,按type筛选。 结果按每页pageSize分页,从startMsgId开始。

Implementation

Future<EMCursorResult<EMMessage?>> fetchHistoryMessages(
  String conversationId, {
  EMConversationType type = EMConversationType.Chat,
  int pageSize = 20,
  String startMsgId = '',
}) async {
  Map req = Map();
  req['con_id'] = conversationId;
  req['type'] = EMConversation.typeToInt(type);
  req['pageSize'] = pageSize;
  req['startMsgId'] = startMsgId;
  Map result =
      await _channel.invokeMethod(EMSDKMethod.fetchHistoryMessages, req);
  EMError.hasErrorFromResult(result);
  return EMCursorResult<EMMessage?>.fromJson(
      result[EMSDKMethod.fetchHistoryMessages], dataItemCallback: (value) {
    return EMMessage.fromJson(value);
  });
}