Overview
Many apps need to recognise a device: to tie a trial or a licence to it, to limit the number of devices per account, or to find a device again after the user has reinstalled the app. KlugDeviceId reads a stable identifier directly from the operating system.
On Android the identifier stays the same after the app is uninstalled and installed again, which makes it a reinstall-proof anchor. On iOS the system identifier is reset when all apps of the same developer are removed; for a reinstall-proof anchor on iOS and macOS use KlugKeychain.
KlugDeviceId is in daily use in the PetCam App, our proof of concept.
Features
- One call returns the device identifier on Android and iOS
- Android: stays the same after uninstalling and reinstalling the app
- No permission needed
- Returns an empty string where no identifier is available, never an error
Supported platforms
On other platforms isSupported returns false, so the same code can stay in a cross-platform app.
Getting started
Add the extension to your application descriptor:
<extensions>
<extensionID>com.klug.deviceid</extensionID>
</extensions>
Quick example
import com.klug.deviceid.DeviceId; if ( DeviceId.getInstance().isSupported ) { var id:String = DeviceId.getInstance().uniqueId; registerDevice( id ); // e.g. limit devices per account }
API overview
| DeviceId.getInstance() | Returns the single instance. |
| isSupported | True on Android and iOS. |
| uniqueId | The device identifier of the running platform, or an empty string. |
| androidId | The Android device identifier only; an empty string on other platforms. |
Requirements
| AIR SDK | 51.x (HARMAN) |
| iOS | iOS 17 or later |
| Android | Android 6.0 (API 23) or later |
| Permissions | None |