42 lines
1.1 KiB
Dart
Executable File
42 lines
1.1 KiB
Dart
Executable File
|
|
import 'dart:io';
|
|
import 'package:device_info_plus/device_info_plus.dart';
|
|
import 'package:get/get.dart';
|
|
import '../../app_settings/app_settings.dart';
|
|
import 'app_manager.dart';
|
|
import 'store_service.dart';
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
class DeviceInfoService extends GetxService {
|
|
static DeviceInfoService get to => Get.find<DeviceInfoService>();
|
|
|
|
String _deviceID = '';
|
|
String get deviceID => _deviceID;
|
|
|
|
Future<DeviceInfoService> init() async {
|
|
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
|
// String dId = StoreService.to.getDeviceId();
|
|
String dId = "";
|
|
if(dId.isNotEmpty){
|
|
dId = const Uuid().v1();
|
|
// StoreService.to.saveDeviceId(dId);
|
|
}
|
|
_deviceID = dId;
|
|
|
|
if(Platform.isAndroid){
|
|
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
|
AppPlatform.setBrandString(androidInfo.brand);
|
|
AndroidBuildVersion buildVersion = androidInfo.version;
|
|
AppPlatform.setSDKInt(buildVersion.sdkInt);
|
|
}
|
|
|
|
if(Platform.isIOS){
|
|
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
|
}
|
|
AppManager().saveDeviceID(deviceID);
|
|
AppLog.log(AppManager().deviceId);
|
|
return this;
|
|
}
|
|
|
|
|
|
} |