How to get unique device id in flutter?

flutter get device info
flutter get imei
how to get device token in flutter
flutter get device mac address
flutter get device phone number
flutter detect device
device preview flutter
android telecom in flutter

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?

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.

device_id, To retrieve the id just import and call String device_id = await DeviceId. getID; . To retrieve the imei call String imei = await DeviceId. getIMEI; . A Flutter plugin for retrieving the uid of a device. To retrieve the id just import and call String device_id = await DeviceId.getID;. To retrieve the imei call String imei = await DeviceId.getIMEI;. To retrieve the meid call String meid = await DeviceId.getMEID;.

I just published a plugin to provide a solution to your problem. It uses Settings.Secure.ANDROID_ID for Android and relies on identifierForVendor and the keychain for iOS to make the behaviour equivalent to Android's. Here's the link.

unique_identifier, A new Flutter plugin for fetching the unique identifier from android and ios. A Flutter plugin to get the ANDROID_ID for android and  You can store this UUID in the Keychain. This way you can set an unique ID for your device.

Use device_info plugin developed by Flutter team itself. This is how you can get IDs on both platform.

In your pubspec.yaml file add this:

dependencies:
  device_info: ^0.4.0+4

Create a method:

Future<String> _getId() async {
  DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  if (Theme.of(context).platform == TargetPlatform.iOS) {
    IosDeviceInfo iosDeviceInfo = await deviceInfo.iosInfo;
    return iosDeviceInfo.identifierForVendor; // unique ID on iOS
  } else {
    AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo;
    return androidDeviceInfo.androidId; // unique ID on Android
  }
}

Use it like:

String deviceId = await _getId();

Source

device_id, How do I get a unique device ID in react native? unique_id #. A new Flutter plugin for getting unique id based on device. Getting Started # String uniqueID = await UniqueId.getID; 0.0.1 #. TODO: Describe initial release.

If you're serving ads you can use ASIdentifierManager. You should only use it for ads. There is no general UDID mechanism provided by the OS on iOS, for privacy reasons.

If you're using firebase_auth plugin you could signInAnonymously and then use the id of the FirebaseUser. This will give you an identifier that is specific to your Firebase app.

How to find your Android Device ID, is by going to the Menu >Settings > About Phone > Status. The IMEI / IMSI / MEID should be present in the phone status setting. I'm trying to use the plugin device_info for getting unique device IDS for both Android and IOS. While iOS does have vendorID, on the Android side there is not a secure ID or something similar. Is it possible to implement it ? I've tryed external libraries but they aren't udated and i think this should be something integrated in to Flutter.

add in your following code in your .yaml file.

device_id: ^0.1.3

add import in your class

import 'package:device_id/device_id.dart';

now get device id from:

String deviceid = await DeviceId.getID;

How to get unique device id in flutter?, There is a plugin called device_info. You can get it here. In iOS there is no way you can get a unique device ID. There is a wok around for this. It would be nice to provide an API to get the Unique Device Id in Flutter.

API to get the Unique Device Id · Issue #326 · flutter/flutter · GitHub, It would be nice to provide an API to get the Unique Device Id in Flutter. @abarth. Let me explain to you this by device_info plugin.. Step 1 Add Dependency . dependencies: flutter: sdk: flutter device_info: ^0.4.0+1 Step 2 Import your file at the beginning

plugins/device_info.dart at master · flutter/plugins · GitHub, Find file Copy path Future<AndroidDeviceInfo> get androidInfo async => The Android hardware device ID that is unique between the device + user and app  The best way to get unique identifier in Android: using unique_identifier to get IMEI . dev_dependencies: unique_identifier: ^0.0.3 String identifier =await UniqueIdentifier.serial; in IOS: Apple no longer allows you to retrieve the IMEI or any other device identification,but you can generate UDID suing:

How to get unique device id in flutter?, How to get unique device id in flutter? Use the below example to get unique device id in flutter. Get unique id device on ios and android Getting Started # Get IMEI (International Mobile Device Identity) for Android devices less than android 10 with runtime permission for android greater than or equal to 10 returns a UUID and get unique identification on ios An alphanumeric string that uniquely identifies a device for the application provider.

Comments
  • How do I get the android device id? can it be retrieved from device_info?
  • if (Platform.isAndroid) { .... identifier = build.androidId; ...} else if (Platform.isIOS) { ..... }
  • I'm not able to build my project with this plugin, something related to SWIFT...
  • I am not using firebase , neither I am serving ads. I need a unique identifier to id the device like Settings.Secure.ANDROID_ID in android. I want to know if there a plugin out there for this or shall I have to make a new one for this ?
  • I don't think what you are asking for is possible on iOS. You can easily identify an app install by writing a guid to a file, though.