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?
2
Answers
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.
If the deviceId is having a value that means it’s the old user else stores a unique value.
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.