10

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

Mahmoud Sabri
  • 713
  • 1
  • 7
  • 22
  • 1
    "uuid" and "uuid_type" are NOT plugins to get the device identifier. Those are dart libraries for the generation of UUIDs (https://en.wikipedia.org/wiki/Universally_unique_identifier) – boformer Oct 28 '18 at 13:03
  • i need to get IMEI code – Mahmoud Sabri Nov 04 '18 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). – Peter O. Nov 23 '18 at 15:50
  • 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](https://pub.dartlang.org/packages/device_info#-installing-tab- "their repository") when trying to use the linked example. – flarkmarup Oct 28 '18 at 11:49

6 Answers6

11

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:

import 'package:device_info/device_info.dart';

final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
      var data = await deviceInfoPlugin.iosInfo;
      identifier = data.identifierForVendor;
Mahmoud Sabri
  • 713
  • 1
  • 7
  • 22
8

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

Fahima Mokhtari
  • 1,691
  • 2
  • 16
  • 30
Gaurav Singh
  • 1,177
  • 12
  • 16
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;
      }
}
Elmer
  • 384
  • 5
  • 19
2

add this plugin in depen https://pub.dartlang.org/packages/imei_plugin

Add this to your package's pubspec.yaml file:

dependencies:
  imei_plugin: ^1.0.0
  1. Install it You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get
Kevin Caicedo
  • 171
  • 1
  • 7
1

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

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

boformer
  • 28,207
  • 10
  • 81
  • 66
0

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

Peter Yu
  • 27
  • 2