persistent_device_id 1.0.0 copy "persistent_device_id: ^1.0.0" to clipboard
persistent_device_id: ^1.0.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 on Androidβ€”even after uninstalling and reinstalling the app.


✨ Features #

  • πŸ”’ Generates a unique ID per device
  • ♻️ Persists across app reinstalls (on Android API β‰₯ 18 with MediaDrm)
  • 🧱 Securely stored using Android Keystore + EncryptedSharedPreferences
  • 🚫 No runtime permissions required
  • πŸ“¦ Simple, asynchronous API

πŸ“¦ Installation #

Add this to your pubspec.yaml:

dependencies:
  persistent_device_id: <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 🚧 Not yet (coming soon)

🧠 How It Works #

  1. On Android (API β‰₯ 18), the plugin attempts to use MediaDrm to derive a hardware-based identifier.

  2. If MediaDrm is unavailable or fails (e.g. on rooted devices), a fallback UUID is generated once and securely stored using:


βœ… Android Requirements #

  • minSdkVersion: 21
  • compileSdkVersion: 34
  • No permissions required

🚧 Limitations #

  • MediaDrm is only available on Android API 18 (Jelly Bean 4.3) and above.
  • On some rooted or modified devices, MediaDrm may fail or behave inconsistently.
  • iOS support is currently not available.

πŸ” 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.

15
likes
150
points
364
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