persistent_device_id 1.1.0 copy "persistent_device_id: ^1.1.0" to clipboard
persistent_device_id: ^1.1.0 copied to clipboard

A Flutter plugin that provides a persistent device ID using Android Keystore and iOS Keychain.

Persistent Device ID Logo

πŸ“± persistent_device_id #

A Flutter plugin that provides a unique, persistent, and secure device identifierβ€”even after reinstalling the app or resetting the device. Supports Android and iOS using system-level cryptography and secure storage.


✨ Features #

  • πŸ”’ Generates a unique and persistent ID per device
  • ♻️ Persists across app reinstalls, cache wipes, and even factory resets (when possible)
  • πŸ›‘οΈ Uses MediaDrm, Android Keystore, and EncryptedSharedPreferences on Android
  • 🍏 Uses Keychain on iOS
  • 🚫 Requires no runtime permissions
  • πŸ“¦ Simple, asynchronous API

πŸ“¦ Installation #

Add this to your pubspec.yaml:

dependencies:
  persistent_device_id: <latest_version>

Then run:

flutter pub get

πŸ› οΈ Usage #

Import the package #

import 'package:persistent_device_id/persistent_device_id.dart';

Get the device ID #

final deviceId = await PersistentDeviceId.getDeviceId();
print("Device ID: $deviceId");

βš™οΈ Supported Platforms #

Platform Support
Android βœ… Yes
iOS βœ… Yes

🧠 How It Works #

This plugin uses different secure layers per platform to persist a device-unique identifier:

Android #

  1. Attempts to derive a hardware-based ID from MediaDrm (API β‰₯ 18).

  2. If MediaDrm is not supported or fails (e.g. on rooted/custom ROM devices), falls back to:

iOS #

  • Uses the Keychain to securely store and persist a generated UUID.

βœ… Android Requirements #

  • minSdkVersion: 21
  • compileSdkVersion: 34
  • No special permissions needed

🚧 Limitations #

  • MediaDrm only available on Android API β‰₯ 18
  • On some custom or rooted ROMs, MediaDrm may be unreliable
  • Factory reset will remove the ID unless hardware-backed
  • On iOS, Keychain-based ID may reset if iCloud Keychain is disabled or device is restored without backup

πŸ” Example #

Clone the repository and run the example app:

cd example
flutter run

πŸ“„ License #

MIT License. Β© 2025 Mael Toukap.


πŸ™‹β€β™‚οΈ Contributing #

Contributions are welcome! Please open an issue or submit a pull request on GitHub

10
likes
150
points
544
downloads

Publisher

verified publishermaeltoukap.me

Weekly Downloads

A Flutter plugin that provides a persistent device ID using Android Keystore and iOS Keychain.

Repository (GitHub)
View/report issues
Contributing

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on persistent_device_id

Packages that implement persistent_device_id