fetchLoggedInDevices method

Future<List<ChatDeviceInfo>> fetchLoggedInDevices({
  1. required String userId,
  2. required String token,
})

~english Gets the devices logged in to the specified account by token. ~end

~chinese 使用 Token 获取指定账号当前登录的设备列表。 ~end

Implementation

Future<List<ChatDeviceInfo>> fetchLoggedInDevices({
  required String userId,
  required String token,
}) async {
  try {
    Map req = {'userId': userId, 'token': token};
    Map result = await platform_interface.Client.instance.callNativeMethod(
      ChatMethodKeys.getLoggedInDevicesFromServer,
      req,
    );
    ChatError.hasErrorFromResult(result);
    List<ChatDeviceInfo> list = [];
    result[ChatMethodKeys.getLoggedInDevicesFromServer]?.forEach((info) {
      list.add(ChatDeviceInfo.fromJson(info));
    });
    return list;
  } catch (e) {
    rethrow;
  }
}