Package 

Object DeviceIdentifier


  • 
    public class DeviceIdentifier
    
                        

    Generates and maintains a unique UUID for the device, stored in SharedPreferences (persists across app updates but cleared on app deletion). The UUID is generated once on first SDK init and reused for all subsequent sessions.

    Thread-safe: synchronized access with in-memory caching for fast lookups.

    Mirrors DeviceIdentifier.swift on iOS (UserDefaults-backed there).

    • Method Summary

      Modifier and Type Method Description
      final Unit init(Context context) Initialise with an application Context.
      final String getOrCreateUUID() Returns the persistent UUID, generating and storing one on first call.
      final Unit reset() Forget the current UUID and remove it from persistent storage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • init

         final Unit init(Context context)

        Initialise with an application Context. Safe to call multiple times. Triggers a one-time generation if no UUID is stored yet.

      • getOrCreateUUID

         final String getOrCreateUUID()

        Returns the persistent UUID, generating and storing one on first call. Falls back to a transient (non-persisted) UUID only if init(context) has not been called yet — callers should init early.

      • reset

         final Unit reset()

        Forget the current UUID and remove it from persistent storage. Mainly for tests; production code should never call this.