skip to Main Content

I wanted to know if there is a prefered way to fetch a unique "ID" from the user of the app.
The thing is that I need to differentiate between phones under one "Company Account".

As it seems, android and apple made it hard for us to get the needed information.

The best shot seems to be:
https://pub.dev/packages/flutter_udid

But I just want to know if there is a better solution?

flutter_udid looks good, but I am a bit surprised that Android/Apple are giving us a hard time fetching a unique device UID

2

Answers


  1. I understand you want to get device id.
    This id is unique and does not change until the device is reset. You can use it for identification.

    platform_device_id: ^1.0.1

    Login or Signup to reply.
  2. Use device_info_plus plugin developed by Flutter community. This is how you can get IDs on both platform.

    In your pubspec.yaml file add this:

    dependencies:
      device_info_plus: ^3.2.3
    

    Create a method:

    Future<String?> _getId() async {
      var deviceInfo = DeviceInfoPlugin();
      if (Platform.isIOS) { // import 'dart:io'
        var iosDeviceInfo = await deviceInfo.iosInfo;
        return iosDeviceInfo.identifierForVendor; // unique ID on iOS
      } else if(Platform.isAndroid) {
        var androidDeviceInfo = await deviceInfo.androidInfo;
        return androidDeviceInfo.androidId; // unique ID on Android
      }
    }
    

    Usage:

    String? deviceId = await _getId();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search