← All extensions

Native extension

KlugDeviceId

com.klug.deviceid

A stable identifier per device for AIR apps on Android and iOS, read directly from the system.

iOSAndroid In production

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

Android arm64 · armv7
iOS arm64

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:

app.xml
<extensions>
    <extensionID>com.klug.deviceid</extensionID>
</extensions>

Quick example

Device.as
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.
isSupportedTrue on Android and iOS.
uniqueIdThe device identifier of the running platform, or an empty string.
androidIdThe Android device identifier only; an empty string on other platforms.

Requirements

AIR SDK51.x (HARMAN)
iOSiOS 17 or later
AndroidAndroid 6.0 (API 23) or later
PermissionsNone