getHistoryMessage static method

Future<NIMResult<List<ChatMessage>>> getHistoryMessage(
  1. NIMMessage anchor,
  2. QueryDirection direction,
  3. int limit
)

获取历史消息

Implementation

static Future<NIMResult<List<ChatMessage>>> getHistoryMessage(
    NIMMessage anchor, QueryDirection direction, int limit) async {
  var msgRes = await NimCore.instance.messageService
      .queryMessageListEx(anchor, direction, limit);
  if (msgRes.isSuccess && msgRes.data != null) {
    List<ChatMessage> result = await fillUserInfo(msgRes.data!);
    result = await _fillPin(anchor.sessionId!, anchor.sessionType!, result);
    return NIMResult(msgRes.code, result, msgRes.errorDetails);
  } else {
    return NIMResult(msgRes.code, null, msgRes.errorDetails);
  }
}