getDeviceInfo static method

Future<Device> getDeviceInfo()

Implementation

static Future<Device> getDeviceInfo() async {
  final deviceInfoPlugin = DeviceInfoPlugin();
  final packageInfo = await PackageInfo.fromPlatform();
  if (Platform.isAndroid) {
    final androidInfo = await deviceInfoPlugin.androidInfo;
    return Device(
      uaClientType: "mobile",
      uaClientName: "player_nova_app",
      uaClientVersion: packageInfo.version,
      uaDeviceType: "phone",
      uaDeviceBrand: androidInfo.brand,
      uaDeviceModel: androidInfo.model,
      uaOsName: "Android",
      uaOsVersion: androidInfo.version.sdkInt.toString(),
      packageName: packageInfo.packageName,
    );
  } else if (Platform.isIOS) {
    final iosInfo = await deviceInfoPlugin.iosInfo;
    return Device(
      uaClientType: "mobile",
      uaClientName: "player_nova_app",
      uaClientVersion: packageInfo.version,
      uaDeviceType: iosInfo.model == "iPhone" ? "phone" : "tablet",
      uaDeviceBrand: "Apple",
      uaDeviceModel: iosInfo.model,
      uaOsName: "iOS",
      uaOsVersion: iosInfo.systemVersion,
      packageName: packageInfo.packageName,
    );
  }
  throw CoreExceptions(
    statusCode: CoreExceptions.implementationError,
    description: 'Unsupported platform',
  );
}