udid_new 0.0.1
udid_new: ^0.0.1 copied to clipboard
A cross-platform Flutter plugin to retrieve unique device identifiers (UDID) on Android and iOS with SHA-256 hashing support and Keychain persistence.
udid_new #
A Flutter plugin to retrieve a unique device identifier (UDID) on Android and iOS platforms. The plugin provides both platform-specific and cross-platform consistent device identifiers.
Features #
- ✅ Retrieve platform-specific device UDID
- iOS: Uses
identifierForVendorUUID with Keychain persistence - Android: Uses Android ID from secure settings
- iOS: Uses
- ✅ Generate consistent SHA-256 hashed UDID across all platforms
- ✅ Automatic migration from legacy Keychain storage (iOS)
- ✅ Error handling with proper exceptions
- ✅ Simple, easy-to-use API
Platform Support #
| Platform | Support | Implementation |
|---|---|---|
| Android | ✅ | Android ID (Settings.Secure.ANDROID_ID) |
| iOS | ✅ | identifierForVendor with Keychain storage |
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
udid_new: ^0.0.1
Then run:
flutter pub get
Usage #
Basic Usage #
import 'package:udid_new/udid_new.dart';
// Get platform-specific UDID
String udid = await Udid.udid;
print('Device UDID: $udid');
// iOS: 7946DA4E-8429-423C-B405-B3FC77914E3E
// Android: 8af8770a27cfd182
Get Consistent UDID (SHA-256) #
For a consistent identifier across all platforms:
import 'package:udid_new/udid_new.dart';
// Get SHA-256 hashed UDID (same format on all platforms)
String consistentUdid = await Udid.consistentUdid;
print('Consistent UDID: $consistentUdid');
// Example: 984725b6c4f55963cc52fca0f943f9a8060b1c71900d542c79669b6dc718a64b
Error Handling #
import 'package:flutter/services.dart';
import 'package:udid_new/udid_new.dart';
try {
String udid = await Udid.udid;
print('Device UDID: $udid');
} on PlatformException catch (e) {
print('Failed to get UDID: ${e.message}');
}
Example #
See the example directory for a complete sample app demonstrating:
- Fetching both platform-specific and consistent UDIDs
- Error handling
- UI implementation
- Loading states
Platform-Specific Information #
Android #
- Method:
Settings.Secure.ANDROID_ID - Format: Hexadecimal string
- Minimum SDK: 21
- Persistence: Device-specific, changes on factory reset
iOS #
- Method:
UIDevice.current.identifierForVendor - Format: UUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)
- Minimum Version: iOS 12.0
- Persistence: Stored in Keychain, persists across app reinstalls
- Migration: Automatically migrates from legacy SAMKeychain storage
API Reference #
Udid.udid #
Returns the device UDID in platform-specific format.
Returns: Future<String>
Throws: PlatformException if UDID is unavailable
Udid.consistentUdid #
Returns a SHA-256 hashed UDID that is consistent across all platforms.
Returns: Future<String> (64-character hex string)
Throws: PlatformException if UDID is unavailable
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
Issues #
If you encounter any issues, please file them on the GitHub issue tracker.
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Credits #
Developed and maintained by Krishnapal Sendhav.