fetchLoggedInDevices method

Future<List<ChatDeviceInfo>> fetchLoggedInDevices(
  1. {required String userId,
  2. required String pwdOrToken,
  3. bool isPwd = true}
)

Gets the list of currently logged-in devices of a specified account.

Param userId The user ID.

Param pwdOrToken The password or token.

Param isPwd Whether a password or token is used: (Default)true: A password is used; false: A token is used.

Return The list of the logged-in devices.

Throws A description of the exception. See ChatError.

Implementation

Future<List<ChatDeviceInfo>> fetchLoggedInDevices({
  required String userId,
  required String pwdOrToken,
  bool isPwd = true,
}) async {
  Map req = {'username': userId, 'password': pwdOrToken, 'isPwd': isPwd};
  Map result = await ClientChannel.invokeMethod(
      ChatMethodKeys.getLoggedInDevicesFromServer, req);
  try {
    ChatError.hasErrorFromResult(result);
    List<ChatDeviceInfo> list = [];
    result[ChatMethodKeys.getLoggedInDevicesFromServer]?.forEach((info) {
      list.add(ChatDeviceInfo.fromJson(info));
    });
    return list;
  } on ChatError catch (e) {
    throw e;
  }
}