提交 cd83a0b8 authored 作者: shixiaochen's avatar shixiaochen

1、增加获取设备唯一标识

上级 b85cb685
import 'dart:io';
import 'package:device_id_plugin/device_id_plugin.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/services.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';
import 'package:unique_identifier/unique_identifier.dart';
class DeviceUtils {
//uuid
static getDeviceSerial() async {
if (Platform.isAndroid) {
String? identifier = "Unknown";
try {
identifier = await UniqueIdentifier.serial ?? "Unknown";
} on PlatformException {
identifier = "Unknown";
}
return identifier;
} else if (Platform.isIOS) {
String? identifier = "Unknown";
try {
// TODO: 2023/7/6 iOS获取序列号
// identifier = await VersionUtils.getUuidForKeychain();
} on PlatformException {
identifier = "Unknown";
}
return identifier;
}
DeviceIdPlugin deviceInfo = DeviceIdPlugin();
return await deviceInfo.getDeviceId();
}
static getVersionName() async {
......
......@@ -60,6 +60,9 @@ dependencies:
unique_identifier: ^0.3.0
# 设备信息 https://pub.dev/packages/device_info_plus
device_info_plus: ^8.1.0
#获取设备id https://t.clxkj:cn/openSourceLibrary/device_id_plugin:git:
device_id_plugin:
git: https://t.clxkj.cn/openSourceLibrary/device_id_plugin.git
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论