getDeviceId method
Implementation
Future<String> getDeviceId() async {
String deviceId = '';
if (Platform.isAndroid) {
final info = await DeviceInfoPlugin().androidInfo;
try {
AndroidId androidIdClass = AndroidId();
deviceId = await androidIdClass.getId() ?? '';
} catch (e) {
deviceId = info.id;
}
} else if (Platform.isIOS) {
final info = await DeviceInfoPlugin().iosInfo;
deviceId = info.identifierForVendor ?? '';
} else {
var message = 'Unsupported platform for device ID retrieval';
logger.warning(this, message);
throw PlatformException(code: 'UNSUPPORTED_PLATFORM', message: message);
}
return deviceId;
}