searchMessage static method

Future<List<ChatMessage>?> searchMessage(
  1. String keyWord,
  2. String sessionId,
  3. NIMSessionType sessionType
)

根据关键字搜索消息

Implementation

static Future<List<ChatMessage>?> searchMessage(
    String keyWord, String sessionId, NIMSessionType sessionType) async {
  MessageSearchOption searchOption =
      MessageSearchOption(searchContent: keyWord);
  var res = await NimCore.instance.messageService
      .searchMessage(sessionType, sessionId, searchOption);
  if (res.isSuccess && res.data != null) {
    List<ChatMessage> tmp = await fillUserInfo(res.data!);
    //Android 返回的不是时间倒序,ios的是,所以区别对待
    if (Platform.isAndroid) {
      return tmp.reversed.toList();
    }
    return tmp.toList();
  }
  return null;
}