fetchPresenceStatus method

Future<List<EMPresence>> 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 EMError. ~end

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

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

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

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

Implementation

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