fetchPresenceStatus method

Future<List<ChatPresence>> fetchPresenceStatus({
  1. required List<String> members,
})

~english Gets the current presence state of users.

Param members The array of IDs of users whose current presence state you want to check.

Return Which contains the users whose presence state you have subscribed to.

Throws A description of the exception. See ChatError. ~end

~chinese 查询指定用户的当前在线状态。

Param members 用户 ID 数组,指定要查询哪些用户的在线状态。

Return 被订阅用户的当前状态。

Throws 如果有方法调用的异常会在这里抛出,可以看到具体错误原因。参见 ChatError。 ~end

Implementation

Future<List<ChatPresence>> fetchPresenceStatus({
  required List<String> members,
}) async {
  Map req = {'members': members};
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.fetchPresenceStatus, req);
  try {
    ChatError.hasErrorFromResult(result);
    List<ChatPresence> list = [];
    result[ChatMethodKeys.fetchPresenceStatus]?.forEach((element) {
      list.add(ChatPresence.fromJson(element));
    });
    return list;
  } on ChatError catch (e) {
    throw e;
  }
}