搜索插件、代码仓与 APP 分类

插件详情v0.4.0

unique_identifier

一个用于从 Android 和 iOS 获取唯一标识符的新 Flutter 插件。

AndroidiOS
近 30 天下载
1.3万
喜欢数
58
Pub 分数
140

安装插件

flutter pub add unique_identifier

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

unique_identifier 包是一个 Flutter 插件,提供了一种简单的方法来在 Android 和 iOS 平台上获取唯一的设备标识符。它利用原生 API 确保可靠且安全的识别,适用于跟踪、授权或用户身份验证等用途。该插件设计轻量且易于集成,设置需求极少。它遵循平台特定的隐私指南,不收集不必要的数据。此包非常适合希望在跨平台环境中实现一致设备识别而无需直接管理原生代码的开发者。

适合场景

  • 设备跟踪
  • 应用许可
  • 用户认证
  • Analytics
  • 会话管理

主要特点

  • 跨平台支持(Android 和 iOS)
  • 简单 API 集成
  • 尊重隐私指南
  • 无需额外权限
  • 安全标识符生成

适合对象

  • 移动应用开发者
  • 认证系统
  • 许可解决方案
  • 分析实施
  • 注重隐私的应用程序

使用建议

  • 标识符在重新安装应用后可能会更改
  • 不适合高安全性加密
  • 依赖于平台特定的实现
  • 在某些地区可能需要用户同意
  • 限于设备级别的唯一性

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Unique Identifier

pub package

A Flutter plugin to get the ANDROID_ID for android and identifierForVendor for iOS platforms.

Installing

dependencies:
  unique_identifier: ^0.4.0
Import
import 'package:unique_identifier/unique_identifier.dart';

How To Use

 dart String _identifier = 'Unknown';
  
 @override
 void initState() {
   super.initState();
   initUniqueIdentifierState();
 }

 Future<void> initUniqueIdentifierState() async {
   String identifier;
   try {
     identifier = await UniqueIdentifier.serial;
   } on PlatformException {
     identifier = 'Failed to get Unique Identifier';
   }

   if (!mounted) return;

   setState(() {
     _identifier = identifier;
   });
 }

 @override
 Widget build(BuildContext context) {
   return new MaterialApp(
     home: new Scaffold(
       appBar: new AppBar(
         title: const Text('Plugin example app'),
       ),
       body: new Center(
         child: new Text('Running on device with id: $_identifier\n'),
       ),
     ),
   );
 }

Bugs & Requests

If you encounter any bugs feel free to open an issue. Raise a ticket on github for suggestions. Pull request are also welcome.

Flutter

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

License

MIT License

NOTE

On Android 8.0 (API level 26) and higher versions of the platform, a 64-bit number (expressed as a hexadecimal string), unique to each combination of app-signing key, user, and device. Values of ANDROID_ID are scoped by signing key and user. The value may change if a factory reset is performed on the device or if an APK signing key changes. For more information about how the platform handles ANDROID_ID in Android 8.0 (API level 26) and higher, see Android 8.0 Behavior Changes. Note: For apps that were installed prior to updating the device to a version of Android 8.0 (API level 26) or higher, the value of ANDROID_ID changes if the app is uninstalled and then reinstalled after the OTA. To preserve values across uninstalls after an OTA to Android 8.0 or higher, developers can use Key/Value Backup. In versions of the platform lower than Android 8.0 (API level 26), a 64-bit number (expressed as a hexadecimal string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device. On devices that have multiple users, each user appears as a completely separate device, so the ANDROID_ID value is unique to each user. Note: If the caller is an Instant App the ID is scoped to the Instant App, it is generated when the Instant App is first installed and reset if the user clears the Instant App.

所属分类

依赖

依赖清单 1 项

  • plugin_platform_interface^2.0.2

源码仓库

使用此插件的项目

暂无相关数据。