简体   繁体   中英

How can I get any unique id flutter android and ios

I need to get a unique information of my device. This may be the mac address, it may be the imei address, or something different, ios and android return a constant value after a certain version and do not give the unique id.
The unique id as currently used changes when the application is deleted and reinstalled. I have a chat system and I don't want some members to come back.

Is there a way to access a device's unique information by obtaining a permission if necessary?

you can use a package called firebase_messaging and get device token

String deviceToken = await FirebaseMessaging.instance.getToken();

To get the IMEI of user phone device_information

String imeiNo = await DeviceInformation.deviceIMEINumber;

device_info_plus

identifierForVendor for ios.
androidId for android

You can control with Platform.ios condition.

In addition, you can store with secure_storage

The token is generated per the client app instance.

On initial startup of your app, the FCM SDK generates a registration token for the client app instance.

See Best practices for FCM registration token management for details.

Only one user at the time is logged in on the app instance. Delete the token when a user logs out and then you get a new token when a new user logs in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM