android_multiple_identifier

Exclusive for Android A plugin that provides multiple Android unique identifiers for you to choose the one that best applies to your needs. This plugin is aimed for projects that need to a unique identifier for Android devices and need multiple options to test in their applications:

  • ANDROID_ID usually works but it is known not to be 100% reliable.
  • IMEI code is unique for each device but only comes with devices that have telephony services. It is also not recommended for other than fraud prevention.
  • Serial Number is also unique for each device but it is only required for devices that do not have telephony services, so it is possible that some devices do not have a serial number (possible but very unlikely).

All there 3 options are provided so you can use the one that best applies to your needs (or maybe multiple options combined).

Permission READ_PHONE_STATE are required but the plugin has a method that takes care of that.

Getting Started

Make sure you add the needed permission to your Android Manifest Permission and Info.plist.

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

API

Android

Be sure to ask permissions first, otherwise, the app won't be able to get the IMEI code and Serial number:

await AndroidMultipleIdentifier.requestPermission();

Then you can call any of the three available methods:

String imei = await AndroidMultipleIdentifier.imeiCode;
String serial = await AndroidMultipleIdentifier.serialCode;
String androidID = await AndroidMultipleIdentifier.androidID;

Or call a map contaning the 3 values so you reduce the times you call native android:

Map idMap = await AndroidMultipleIdentifier.idMap;

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

Android Permissions

Besides the request permission method:

await AndroidMultipleIdentifier.requestPermission();

You can use methods for checking status of the permissions:

bool permissionStatus = await AndroidMultipleIdentifier.checkPermission(); // true if the permission is already granted
bool isPermissionRejected = await AndroidMultipleIdentifier.checkPermissionRationale(); // true if the user previously rejected the app
bool setToNeverAskAgain = AndroidMultipleIdentifier.neverAskAgain; //true if the user rejected the app and set to never ask again

For openning settings (and modifiying permissions manually):

AndroidMultipleIdentifier.openSettings();

Check Platform Version

Just in case you need it:

platformVersion = await AndroidMultipleIdentifier.platformVersion;

iOS

For now the iOs functionality has been disabled. The app won't crash on iOS if you add it to your pubspec.yaml file.

Libraries

android_multiple_identifier

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]