fluttercommunity / android_id

Maintainer: @nohli
https://pub.dev/packages/android_id
BSD 3-Clause "New" or "Revised" License
34 stars 16 forks source link

Ids are not unique #56

Closed telestia closed 1 year ago

telestia commented 1 year ago

I got same id on 2 different Android device, should I use fingerprint for unique deviceId?

DeviceId is: TP1A.220624.014

nohli commented 1 year ago

The string you provided is no Android ID:

https://distrowiki.miraheze.org/wiki/Android_13_build_TP1A.220624.014

How did you get it?

telestia commented 1 year ago

var deviceInfo = DeviceInfoPlugin(); if (Platform.isAndroid) { AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; deviceId = androidInfo.id; } else if (Platform.isIOS) { IosDeviceInfo iosInfo = await deviceInfo.iosInfo; deviceId = iosInfo.identifierForVendor; }

nohli commented 1 year ago

Makes sense. This id is not unique.

Since you've posted this issue in the android_id package: Are you looking for a unique id for Android? Please refer to the readme of this plugin 😊

But maybe just generating and storing a uuid per device would make more sense? Like https://github.com/fluttercommunity/android_id/issues/45#issuecomment-1604466963.

On a side note, you could make use of the final keyword if a variable doesn't change any more. Using a lint package can show these kinds of hints and can be helpful when learning to code.

telestia commented 1 year ago

Thank you for your answer and your advice.