Browse Source

1、请求添加imei和idf

tags/0.0.2+5
PH2 4 years ago
parent
commit
10c468ab1f
2 changed files with 19 additions and 1 deletions
  1. +18
    -0
      lib/util/net_util.dart
  2. +1
    -1
      pubspec.yaml

+ 18
- 0
lib/util/net_util.dart View File

@@ -7,6 +7,7 @@ import 'package:device_info/device_info.dart';
import 'package:dio/adapter.dart'; import 'package:dio/adapter.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:imei_plugin/imei_plugin.dart';
import 'package:package_info/package_info.dart'; import 'package:package_info/package_info.dart';
import 'package:zhiying_comm/util/empty_util.dart'; import 'package:zhiying_comm/util/empty_util.dart';
import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:zhiying_comm/zhiying_comm.dart';
@@ -269,6 +270,10 @@ class NetUtil {
params['device_model'] = iosInfo?.name?.toString(); params['device_model'] = iosInfo?.name?.toString();
// 设备ID // 设备ID
params['device_id'] = iosInfo?.identifierForVendor?.toString(); params['device_id'] = iosInfo?.identifierForVendor?.toString();

// idfa
params['idfa'] = iosInfo?.identifierForVendor?.toString();

} else if (Platform.isAndroid) { } else if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo; AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
// 设备 // 设备
@@ -279,6 +284,9 @@ class NetUtil {
params['device_model'] = androidInfo?.model?.toString(); params['device_model'] = androidInfo?.model?.toString();
// 设备Id // 设备Id
params['device_id'] = androidInfo?.androidId?.toString(); params['device_id'] = androidInfo?.androidId?.toString();

// imei
params['imei'] = await _getImei();
} }
// 应用版本号 // 应用版本号
params["app_version_name"] = packageInfo.version?.toString(); params["app_version_name"] = packageInfo.version?.toString();
@@ -322,6 +330,16 @@ class NetUtil {
return params; return params;
} }


/// 获取Android imei
static Future<String> _getImei() async{
try{
return await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: true);
}catch(e, s){
Logger.error(e, s);
}
return null;
}

/// 获取请求缓存成功的数据 /// 获取请求缓存成功的数据
static Future<void> _onCallBackCacheData(OnCache onCache, String cacheKey) async { static Future<void> _onCallBackCacheData(OnCache onCache, String cacheKey) async {
// 读取缓存 // 读取缓存


+ 1
- 1
pubspec.yaml View File

@@ -46,7 +46,7 @@ dependencies:
url_launcher: ^5.6.0 url_launcher: ^5.6.0
#图片预览控件 #图片预览控件
photo_view: ^0.10.2 photo_view: ^0.10.2
imei_plugin: 1.2.0


loading_indicator: ^1.2.0 loading_indicator: ^1.2.0




Loading…
Cancel
Save