getDeviceId method
Implementation
Future<String> getDeviceId() async {
if (GetPlatform.isAndroid) {
// return android.id;
BaseDeviceInfo deviceInfo = await deviceInfoPlugin.deviceInfo;
String deviceId = (deviceInfo.data['androidId'] ?? "").toString();
if (deviceId.isEmpty) {
// ! double check
deviceId = await androidIdPlugin.getId() ?? "";
}
if (deviceId.isEmpty) {
// ! Force check
AndroidDeviceInfo android = await deviceInfoPlugin.androidInfo;
deviceId = android.id;
}
return deviceId;
} else {
IosDeviceInfo ios = await deviceInfoPlugin.iosInfo;
return ios.identifierForVendor ?? "";
}
}