From 10c468ab1fbafb9befb071a18468e35d34831044 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Sat, 14 Nov 2020 17:45:21 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=AF=B7=E6=B1=82=E6=B7=BB=E5=8A=A0i?= =?UTF-8?q?mei=E5=92=8Cidf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/util/net_util.dart | 18 ++++++++++++++++++ pubspec.yaml | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) 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