getDeviceId method
Implementation
Future<String?> getDeviceId() async {
try {
if (Platform.isAndroid) {
const platform = MethodChannel(Env.channelName);
final String? id = await platform.invokeMethod('getAndroidId');
return id;
} else {
final deviceInfo = DeviceInfoPlugin();
final iosInfo = await deviceInfo.iosInfo;
return iosInfo.identifierForVendor;
}
} on MissingPluginException catch (e) {
debugPrint("Device ID plugin not found: ${e.message}");
return "";
} on PlatformException catch (e) {
debugPrint("Failed to get device ID: '${e.message}'.");
return "";
}
}