13

how can i get device IMEI in flutter i'm trying to get Unique Identifier using the following plugins:

uuid_type: ^0.7.0-dev
uuid: ^1.0.3
unique_identifier: ^0.0.3
flutter_udid: ^0.0.3 

all of them geting ID but not the same IMEI ID for device

and when i try to use device_info plugin from this example DeviceInfoPlugin i get error :

Multiple projects in this build have project

4
  • Have you tried only have one of the dependencies at a time? I assume you have imported the device_info as a dependency as specified at their repository when trying to use the linked example. Commented Oct 28, 2018 at 11:49
  • 1
    "uuid" and "uuid_type" are NOT plugins to get the device identifier. Those are dart libraries for the generation of UUIDs (en.wikipedia.org/wiki/Universally_unique_identifier) Commented Oct 28, 2018 at 13:03
  • i need to get IMEI code Commented Nov 4, 2018 at 13:20
  • Even if something allowed you to retrieve a device's IMEI (or any other unique device identifier), using the IMEI to grant access is generally a bad idea (see, e.g., RFC 7254 sec. 8). Commented Nov 23, 2018 at 15:50

5 Answers 5

12

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 using:

import 'package:device_info/device_info.dart';

final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
final data = await deviceInfoPlugin.iosInfo;
identifier = data.identifierForVendor;
Sign up to request clarification or add additional context in comments.

3 Comments

` String identifier =await UniqueIdentifier.serial;` This returns androidID not IMEI.
Is there a modern solution available? unique_identifier doesn't work anymore :/
9

Android no longer allows you to access the IMEI or any other device identifier starting from android 10. Third party apps can not use IMEI & the serial number of a phone and other non-resettable device identifiers. So, now you can't access:

getSerial(),

getImei(),

getDeviceId(),

getSimSerialNumber(),

getSubscriberId()

You have to use another unique identifier for this like Android ID

Please refer: https://developer.android.com/preview/privacy/data-identifiers#device-ids

Comments

3

I was looking for the device serial number.

The following plugin did the trick for me:

android_multiple_identifier

Modify pubspec.yaml:

dependencies:
    android_multiple_identifier: ^1.0.3

Add the permission to AndroidManifest.xml:

Location -> android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my_app_name">

    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

Create a class and access the information:

import 'package:android_multiple_identifier/android_multiple_identifier.dart';

class DeviceInfo {

    Future<String> getDeviceSerialNumber() async {
        // Ask user permission
        await AndroidMultipleIdentifier.requestPermission();
        // Get device information async
        Map idMap = await AndroidMultipleIdentifier.idMap;

        String imei = idMap["imei"];
        String serial = idMap["serial"];
        String androidID = idMap["androidId"];

        return imei;
      }
}

2 Comments

doesn't support null safety
Dart 3 incompatible
1

Apple no longer allows you to retreive the IMEI or any other device identificator:

https://stackoverflow.com/a/19927376/2461957

Comments

0

I just meet the same question, and tried pakage platform_device_id, and found the device id changed when I changed the internet

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.