0

So is there any way in Flutter to get some sort of device id that won't change when doing a factory reset or changing the signing key? According to the documentation, I did not find any way to extract a constant id throughout the entire use of the application on the device..

I tried solution with 'package:uuid/uuid.dart' package but generated id is same on every device, so is there any solution to track device id of more devices so i can store user actions of specific device?

  • Can you tell me the exact use case you are solving for, iOS and android both don't expose unique device ids (IMEI, etc) because these will be used by advertisers. There might be a different way of solving your issue without needing a constant device id. – Advait Jun 06 '23 at 08:23
  • @Advait i need device id, because use case is: to store specific device id and action that user executed from specific device. I created app for one company that will use app on let's say 40 devices. I want to know from which device is action triggered. we first used androidId solution but we found out that it can change so it's not reliable.. – Dario Lucić Jun 06 '23 at 09:08

2 Answers2

0

You can use flutter_secure_storage to implement this.

Please use await storage.write(key: 'device_id', value: value) when you've installed the app the first time.

On the next install, you need to check If the value exists or not. Please use the below method to check value exists or not.

final deviceId = await storage.read(key: key)

If the deviceId is having a value that means it's the old user else stores a unique value.

Hitesh Surani
  • 12,733
  • 6
  • 54
  • 65
  • This might work on iOS because of keychain, but won't work on android. Android clears all data when the app in uninstalled. – Advait Jun 06 '23 at 08:22
  • I'm already using storage but that's not what I asked, for my use case I need to know can I get some device identifier that won't change. – Dario Lucić Jun 06 '23 at 09:12
0

Currently there is no way to get an id that's static globally unique and reliable device identifier.

I'm attaching a link to an answer which goes into the details of why this is the case.

This has to be solved on a per use basis, if the devices are going to be used by people inside the org, you can have a phone number OTP based login to verify the phone.

If you can describe your use case in detail, in terms of environment of usage, expected user base, etc, I'm happy to help you brainstorm a solution.

Advait
  • 574
  • 3
  • 12