cGetDeviceId function

Future<String> cGetDeviceId()

Retrieves the device ID for various platforms, including iOS, Android, Windows, Linux, Web, and macOS.

Usage:

String deviceId = await cGetDeviceId();
print("Device ID: $deviceId");

Implementation

Future<String> cGetDeviceId() async {
  var deviceInfo = DeviceInfoPlugin();
  if (cIsIOS) {
    var iosDeviceInfo = await deviceInfo.iosInfo;
    return iosDeviceInfo.identifierForVendor ?? 'ios Error';
  } else if (cIsAndroid) {
    var androidDeviceInfo = await deviceInfo.androidInfo;
    return androidDeviceInfo.id;
  } else if (cIsWindows) {
    var windowsDeviceInfo = await deviceInfo.windowsInfo;
    return windowsDeviceInfo.deviceId;
  } else if (cIsLinux) {
    var linuxDeviceInfo = await deviceInfo.linuxInfo;
    return linuxDeviceInfo.id;
  } else if (cIsWeb) {
    var webDeviceInfo = await deviceInfo.webBrowserInfo;
    return "${webDeviceInfo.vendor ?? ' <=> '} : ${webDeviceInfo.userAgent ?? ' <=> '} : ${webDeviceInfo.hardwareConcurrency ?? ' <=> '}";
  } else if (cIsMacOS) {
    var macDeviceInfo = await deviceInfo.macOsInfo;
    return macDeviceInfo.systemGUID ?? 'mac os error';
  } else {
    return 'Platform currently not supported';
  }
}