As soon as the SDK starts for the first time, a Device ID is assigned to that specific installation of your app.
The Device ID assigned to an installation might change in case of rare events, for example if the local storage of the device gets erased.
The SDK provides two different ways to obtain the Device ID.
The first method to obtain the Device ID is to set a IDeviceIdListener
, as shown in the example below. When a listener is set, the SDK immediately returns the Device ID through the onDeviceIdAvailable()
callback if the Device ID is already available. Otherwise, it will call the callback method as soon as the ID is obtained.
The best practice for an app that want to collect on a backend systems the Device ID assigned to each installation, is to set a
IDeviceIdListener
each time it starts. The mobile app would receive the Device ID each time and should always send it to the backend system. Then, the backend system should overwrite any previously stored value if the new received value is different.
The second way is to call the GeoUniq.getDeviceId()
method. This method returns the value of the Device ID if it has already been obtained or null
if the Device ID has not been obtained yet.