颤振,获取最重要的设备信息

时间:2020-08-04 13:58:48

标签: flutter dart

我目前正在使用this library来获取Ios和Android的设备信息。

我想为每个用户使用唯一的标识符(设备ID)添加到数据库中,但是我不知道要存储哪些属性以及使用哪个ID。

所以这是一个问题:在以下所有设置中,哪些设置对存储在数据库中很重要?唯一的设备ID是哪一个? (对于 Ios android

Map<String, dynamic> _readAndroidBuildData(AndroidDeviceInfo build) {
    return <String, dynamic>{
      'version.securityPatch': build.version.securityPatch,
      'version.sdkInt': build.version.sdkInt,
      'version.release': build.version.release,
      'version.previewSdkInt': build.version.previewSdkInt,
      'version.incremental': build.version.incremental,
      'version.codename': build.version.codename,
      'version.baseOS': build.version.baseOS,
      'board': build.board,
      'bootloader': build.bootloader,
      'brand': build.brand,
      'device': build.device,
      'display': build.display,
      'fingerprint': build.fingerprint,
      'hardware': build.hardware,
      'host': build.host,
      'id': build.id,
      'manufacturer': build.manufacturer,
      'model': build.model,
      'product': build.product,
      'supported32BitAbis': build.supported32BitAbis,
      'supported64BitAbis': build.supported64BitAbis,
      'supportedAbis': build.supportedAbis,
      'tags': build.tags,
      'type': build.type,
      'isPhysicalDevice': build.isPhysicalDevice,
      'androidId': build.androidId,
      'systemFeatures': build.systemFeatures,
    };
  }

  Map<String, dynamic> _readIosDeviceInfo(IosDeviceInfo data) {
    return <String, dynamic>{
      'name': data.name,
      'systemName': data.systemName,
      'systemVersion': data.systemVersion,
      'model': data.model,
      'localizedModel': data.localizedModel,
      'identifierForVendor': data.identifierForVendor,
      'isPhysicalDevice': data.isPhysicalDevice,
      'utsname.sysname:': data.utsname.sysname,
      'utsname.nodename:': data.utsname.nodename,
      'utsname.release:': data.utsname.release,
      'utsname.version:': data.utsname.version,
      'utsname.machine:': data.utsname.machine,
    };
  }

1 个答案:

答案 0 :(得分:0)

对于Android,您需要androidId。根据文档,这

在设备+用户和应用程序签名之间是唯一的

对于iOS,您需要identifierForVendor。根据文档,这是一个

标识当前设备的唯一UUID值。

这两个都是唯一的标识符,因此它们应该能够在数据库中用于标识而不会产生冲突。