How to get the serial number (not the IMEI) of iOS and Android devices?

Asked

Viewed 1,859 times

1

How to get the serial number of a mobile device?

I need the solution in Adobe, firemonkey that works on both Android and iOS.

  • 1

    I believe that there is no such thing, in iOS formerly existed the UDID that if I am not mistaken Apple does not allow it to be used anymore, already in Android I do not know anything of this type, let alone something that worked the same in both, that in the case it would have to be something proper to Firemonkey that abstracts the resource of the operating system, and in general something that can uniquely identify any device is very badly seen by users

  • 1

    In iOS, if you’re referring to the device’s UDID, there’s no way you can get the UDID, there are some ways it "generates" a kind of UDID but it’s not the real one. As an example, just download an app from the apple store to capture it.

3 answers

1

Add Androidapi.JNI.Os and use the following function:

JStringToString(TJBuild.JavaClass.SERIAL);

1

Solution for Android.

In Delphi I have no idea, but you can search the native classes of android, as if it were in Java (I believe) and try to do something similar.

In java:

android.telephony.TelephonyManager.getDeviceId()

This code snippet will return a string with device identification (IMEI in GSM and MEID in CDMA).

For this to work, it is necessary to use the permission:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

For more details, click here!

  • 1

    Thanks for the tip, I’ll check. Actually what I need is to encrypt an information and add it to an INI file. (this routine is already ready and partially working). The file will be used to authenticate the user without the user having to provide login and password always to enter the app. I would like to encrypt this information using the device id as part of the key, thus preventing the INI file from being copied to another device releasing access. My biggest difficulty is getting this dipositivo ID.

  • 1

    Device ID and IMEI are two different things.

  • Using MAC Address would not be an alternative in this case?

0

getDeviceId()

Returns the Unique device ID of a Subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available.

Source: https://developer.android.com/reference/android/telephony/TelephonyManager

Remember that this method is obsolete in API level 26.

To get the IMEI, on Android, you can try the method below:

 TelephonyManager tm = (TelephonyManager)
        getSystemService(this.TELEPHONY_SERVICE);
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        String imei = telephonyMgr.getImei();
 } else {
        String imei = telephonyMgr.getDeviceId();
 }

It is worth remembering that, in some cases, the Device ID can change. Different from IMEI, which is always unique.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.