more info plugin by Scott Harrison

I’ve never heard of it returning nil, but I’ve seen it return an empty string on some platforms, like HTML.

I’ve personally only used system.getInfo( "deviceID" ) to try to identify a specific developer’s device or to generate a device specific random seed.

Hi XeduR,

it returns nil if the permission was denied by users … I attached a sample code

in the original sample code the app was prompting for exit if the permission was denied, but if you remove this line of code and allow users to deny the permission it will return nil, and I didn’t want to force users to allow permissions in my app, so I had to remove it.

Many people deny certain permissions by default like location, accessing storage and contacts etc.

But eventually I shouldn’t rely on DeviceID for what I was using it for
Device_ID.zip (66.0 KB)

@kakula You may be referring to a different thing than I am.

You don’t need android.permission.READ_PHONE_STATE in order to use system.getInfo( "deviceID" ). In fact, I haven’t used that request because it is very invasive in my opinion.

Here’s an excerpt from the docs on the matter, which I had previously linked to:

On Android, if your app uses the "android.permission.READ_PHONE_STATE" permission, this will return IMEI for GSM phones, MEID or ESN for CDMA phones, or the operating system’s unique ID for devices that are not phones. If your Android app does not use the "android.permission.READ_PHONE_STATE" permission, the operating system’s unique ID will be returned for all devices. Note that the operating system’s unique ID may change after re-installing the operating system on the device.

So, you can use system.getInfo( "deviceID" ) without worries, but it isn’t the true device ID. It’s just something that Android OS gives your app and this value changes over time. It doesn’t just change when the OS is reinstalled, but perhaps also with software updates. I’m not sure on when it changes, I just know that it does.

As I mentioned, my only use for this API call has been to, on first launch, generate random seeds, random user IDs, or to check if the device belongs to a developer.

I wasn’t using this permission, but when it started to give problems for newer phones I had to use it, then I stopped using it again because users deny permissions… Or I might have done something wrong but i remember that the app crashed for this issue for some phones after updating the app on the playstore

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.