← All extensions

Native extension

KlugDeviceId

com.klug.deviceid

NO APM NEEDED. Download and enjoy. It can’t get any simpler. Just update the Adobe AIR SDK. If you need help, we are here.

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

iOSAndroid In production From €9 / year · Buy

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 our apps, our proof of concept.

Features

  • Self-contained: one ANE, no core library or dependency ANEs to add
  • One call returns the device identifier on Android and iOS
  • Android 8.0 and later: stays the same after uninstalling and reinstalling the app, as long as it is signed with the same key
  • 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>

Code examples

Three complete flows. The getters return at once, need no permission and never throw: where no identifier is available they return an empty string. Full documentation →

1 · Read once and send it with the login
Login.as
import com.klug.deviceid.DeviceId;
import flash.events.Event;
import flash.net.*;

// read once at start and keep it: ANDROID_ID on Android, identifierForVendor on iOS
var deviceId:String = DeviceId.getInstance().uniqueId;

function login( user:String, password:String ):void
{
    var vars:URLVariables = new URLVariables();
    vars.user     = user;
    vars.password = password;
    vars.device   = deviceId;     // your server binds the licence or the push token to it

    var req:URLRequest = new URLRequest( "https://your.server/login" );
    req.method = URLRequestMethod.POST;
    req.data   = vars;

    var loader:URLLoader = new URLLoader();
    loader.addEventListener( Event.COMPLETE, onLoginResult );
    loader.load( req );
}
2 · Keep a trial across reinstall (Android)
Trial.as
var dev:DeviceId = DeviceId.getInstance();

// Android: ANDROID_ID stays the same after uninstall and reinstall; only a
// factory reset changes it. From Android 8 it is specific to your signing key.
var anchor:String = dev.androidId;

if ( anchor != "" )
    checkTrial( anchor );     // your server: has this device used the trial before?
else
    checkTrialOnIOS();        // iOS: androidId is always "" and identifierForVendor is
                              // reset on uninstall, use KlugKeychain as the anchor there
3 · Cross-platform code and empty values
Device.as
import flash.utils.setTimeout;

function readDeviceId():void
{
    var dev:DeviceId = DeviceId.getInstance();
    if ( !dev.isSupported )
    {
        useOwnDesktopId();        // desktop: isSupported is false, every getter returns ""
        return;
    }

    var id:String = dev.uniqueId;
    if ( id == "" )
        setTimeout( readDeviceId, 1000 );   // iOS can briefly have no value: ask again
    else
        onDeviceId( id );
}

API overview

DeviceId.getInstance()Returns the single instance.
isSupportedTrue on Android and iOS.
uniqueIdThe device identifier of the running platform: ANDROID_ID on Android, identifierForVendor on iOS; an empty string where not available.
androidIdThe Android device identifier only, which stays the same after uninstall and reinstall; an empty string on iOS and other platforms.

Buy KlugDeviceId

A yearly licence for one AIR application, with all updates for 12 months. After payment you receive the extension, the ActionScript library and the documentation by e-mail, usually within one business day. Licence and terms

Simple
€9 / year
  • Licence for one AIR application
  • All updates for 12 months
  • No support
Buy Simple
Standard
€39 / year
  • Licence for one AIR application
  • All updates for 12 months
  • Answer by e-mail within 7 days
Buy Standard
Priority
€79 / year
  • Licence for one AIR application
  • All updates for 12 months
  • Answer by e-mail within 48 hours
Buy Priority
Taxes are calculated at checkout by Link (Stripe). You enter the application ID of your AIR app during checkout.

Requirements

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