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
Apple no longer allows you to retreive the IMEI or any other device identificator:
https://stackoverflow.com/a/19927376/2461957
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
- Install it
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter packages get
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;
}
}
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;