getMessagesDynamically static method

Future<NIMResult<MessageDynamicResult>> getMessagesDynamically(
  1. GetMessagesDynamicallyParam param, {
  2. bool enablePin = true,
  3. bool addUserInfo = true,
})

动态途径获取消息,默认从本地获取,动态能力需要开通功能,并在同步完成后生效

Implementation

static Future<NIMResult<MessageDynamicResult>> getMessagesDynamically(
    GetMessagesDynamicallyParam param,
    {bool enablePin = true,
    bool addUserInfo = true}) async {
  var msgRes =
      await NimCore.instance.messageService.getMessagesDynamically(param);
  if (msgRes.isSuccess &&
      msgRes.data != null &&
      msgRes.data!.messages != null) {
    List<ChatMessage> result;
    if (addUserInfo) {
      result = await fillUserInfo(msgRes.data!.messages!);
    } else {
      result = msgRes.data!.messages!.map((e) => ChatMessage(e)).toList();
    }
    if (enablePin) {
      result = _fillPin(param.sessionId, param.sessionType, result);
    }
    return NIMResult(
        msgRes.code,
        MessageDynamicResult(
            messageList: result, isReliable: msgRes.data!.isReliable),
        msgRes.errorDetails);
  } else {
    return NIMResult(msgRes.code, null, msgRes.errorDetails);
  }
}