getUniqueIdentifier method

  1. @override
Future<String?> getUniqueIdentifier()
override

Returns the unique device identifier for the current platform.

May return null if the platform cannot provide a valid identifier.

Platform behavior:

  • Android: Returns Settings.Secure.ANDROID_ID
  • iOS: Returns UIDevice.identifierForVendor
  • macOS: Returns IOPlatformUUID using IOKit (macOS 12+: kIOMainPortDefault, older: kIOMasterPortDefault)
  • Windows: Reads the registry value HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid
  • Linux: Reads from /etc/machine-id
  • Web: Returns a fingerprint-based hash if possible; otherwise, a random UUID is generated and stored in localStorage

Implementation

@override
Future<String?> getUniqueIdentifier() {
  return methodChannel.invokeMethod<String>('get_unique_identifier');
}