In Android we have, Settings.Secure.ANDROID_ID
. I do not know the iOS equivalent. Is there a flutter plugin or a way to get a unique device id for both Android and IOS in flutter?
If you need only the id of the device that your app is running on, the simplest and quickest solution is to use the platform_device_id package. It works on Android (AndroidId), iOS (IdentifierForVendor), Windows (BIOS UUID), macOS (IOPlatformUUID), and Linux (BIOS UUID).
We can get current device information from within the Flutter application by using the device_info_plus package. Which is supports all kinds of platforms, including Android, iOS, macOS, web, Linux, and Windows.
There is a plugin called device_info. You can get it here.
Check the official example here
static Future<List<String>> getDeviceDetails() async { String deviceName; String deviceVersion; String identifier; final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin(); try { if (Platform.isAndroid) { var build = await deviceInfoPlugin.androidInfo; deviceName = build.model; deviceVersion = build.version.toString(); identifier = build.androidId; //UUID for Android } else if (Platform.isIOS) { var data = await deviceInfoPlugin.iosInfo; deviceName = data.name; deviceVersion = data.systemVersion; identifier = data.identifierForVendor; //UUID for iOS } } on PlatformException { print('Failed to get platform version'); } //if (!mounted) return; return [deviceName, deviceVersion, identifier]; }
You can store this UUID in the Keychain. This way you can set an unique ID for your device.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With