Search code examples
ioscodenameoneimei

Codename One - Get IMEI from iOS device


I need to know the IMEI number of iOS devices, running my Codename One app.

Reading that, it seems it's not possible. Is it still impossible to get the IMEI number? And about the serial number? Any workaround to suggest?


Solution

  • In general, iOS does not let you get at persistent unique identifiers (the IMEI, the UDID, the Wi-Fi MAC address, and so on) (source).

    In the developer guide of Codename One, it's written:

    Don’t use an app to get the UDID! Most return the wrong value, the official way to get the UDID is thru itunes.

    If you need to identify uniquely the device, the best that you can do is to use the Codename One method Log.getUniqueDeviceId().

    According to its Javadoc:

    Returns a server generated unique device id that is cached locally and is only valid per application. Notice that this device id is specific to your application and to a specific install, it is guaranteed to be completely unique or -1 if unavailable (which can be due to a network error). Warning: this method might block while accessing the server!