flutter_device_identifier

Last updated:

0 purchases

flutter_device_identifier Image
flutter_device_identifier Images
Add to Cart

Description:

flutter device identifier

flutter_device_identifier #
THIS IS THE VERSION OF https://pub.dev/packages/android_multiple_identifier WITH NULL SAFETY.
Thanks @ahguerra93 for the contribution.
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" />

copied to clipboard
API #
Android #
Be sure to ask permissions first, otherwise, the app won't be able to get the IMEI code and Serial number:
await FlutterDeviceIdentifier.requestPermission();
copied to clipboard
Then you can call any of the three available methods:
String imei = await FlutterDeviceIdentifier.imeiCode;
String serial = await FlutterDeviceIdentifier.serialCode;
String androidID = await FlutterDeviceIdentifier.androidID;
copied to clipboard
Or call a map contaning the 3 values so you reduce the times you call native android:
Map idMap = await DeviceIdentifier.idMap;

String imei = idMap["imei"];
String serial = idMap["serial"];
String androidID = idMap["androidId"];
copied to clipboard
Android Permissions #
Besides the request permission method:
await FlutterDeviceIdentifier.requestPermission();
copied to clipboard
You can use methods for checking status of the permissions:
bool permissionStatus = await FlutterDeviceIdentifier.checkPermission(); // true if the permission is already granted
bool isPermissionRejected = await FlutterDeviceIdentifier.checkPermissionRationale(); // true if the user previously rejected the app
bool setToNeverAskAgain = FlutterDeviceIdentifier.neverAskAgain; //true if the user rejected the app and set to never ask again
copied to clipboard
For openning settings (and modifiying permissions manually):
FlutterDeviceIdentifier.openSettings();
copied to clipboard
Check Platform Version #
Just in case you need it:
platformVersion = await FlutterDeviceIdentifier.platformVersion;
copied to clipboard
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.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.