diff --git a/lib/util/net_util.dart b/lib/util/net_util.dart index 362c76c..c4f651e 100644 --- a/lib/util/net_util.dart +++ b/lib/util/net_util.dart @@ -7,6 +7,7 @@ import 'package:device_info/device_info.dart'; import 'package:dio/adapter.dart'; import 'package:dio/dio.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import 'package:imei_plugin/imei_plugin.dart'; import 'package:package_info/package_info.dart'; import 'package:zhiying_comm/util/empty_util.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -269,6 +270,10 @@ class NetUtil { params['device_model'] = iosInfo?.name?.toString(); // 设备ID params['device_id'] = iosInfo?.identifierForVendor?.toString(); + + // idfa + params['idfa'] = iosInfo?.identifierForVendor?.toString(); + } else if (Platform.isAndroid) { AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo; // 设备 @@ -279,6 +284,9 @@ class NetUtil { params['device_model'] = androidInfo?.model?.toString(); // 设备Id params['device_id'] = androidInfo?.androidId?.toString(); + + // imei + params['imei'] = await _getImei(); } // 应用版本号 params["app_version_name"] = packageInfo.version?.toString(); @@ -322,6 +330,16 @@ class NetUtil { return params; } + /// 获取Android imei + static Future _getImei() async{ + try{ + return await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: true); + }catch(e, s){ + Logger.error(e, s); + } + return null; + } + /// 获取请求缓存成功的数据 static Future _onCallBackCacheData(OnCache onCache, String cacheKey) async { // 读取缓存 diff --git a/pubspec.yaml b/pubspec.yaml index e4ad855..00c1c83 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,7 +46,7 @@ dependencies: url_launcher: ^5.6.0 #图片预览控件 photo_view: ^0.10.2 - + imei_plugin: 1.2.0 loading_indicator: ^1.2.0