I am making an app with token based system. So users can buy tokens and using them they can make some actions. Each user gets 10 tokens for free (as a trial version) after creating an account using email and password.
I want to prevent that user gets another 10 tokens by getting a new account each time and I was wondering if there is something like unique device ID for both Android and iOS devices?
Can I use this for that purpose? https://pub.dartlang.org/packages/device_id#-example-tab-
Use device_info_plus plugin.
In your pubspec.yaml
file add this
dependencies:
device_info_plus: any
Create a method:
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
// ...
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 {
var androidDeviceInfo = await deviceInfo.androidInfo;
return androidDeviceInfo.androidId; // Unique ID on Android
}
}
Use it like:
String? deviceId = await _getId();
or
_getId().then((id) {
String? deviceId = id;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With