Open devsgtech opened 4 years ago
same issue in my case , I am not able to fix that .
i got same issue, any solution?
I got this error also, someone managed to find an alternative?
I think no one is managing it and I am also getting issue with permission . I have added android phone state permission but in many device I am getting null .Anyone have any idea ?
You can try this link https://ionicframework.com/docs/native/uid
You can try this link https://ionicframework.com/docs/native/uid
The native pluggin of ionic refferes to this same code so...
Any update ?
I have this problem too :(
Same issue ...will this be updated soon?
If anyone finds an alternative please post back..thanks.
I used https://ionicframework.com/docs/v3/native/device/. (uuid of it ) . this is only way to work
Does the uuid persist across multiple installs?
yes , I tried with multiple device and multiple install & uninstall . It is working fine and I am using in end user app . I didn't get any issue yet . You should try and check .
@Anujmoglix Will test and report back ...thanks.
I used https://ionicframework.com/docs/v3/native/device/. (uuid of it ) . this is only way to work
I had moved away from that plugin for UUIDs to this one because the UUID didn't persist between installs on iOS, guess i'll have to use both until there is a fix for android on this one.
I managed to solve the issue by updating few lines in UniqueDeviceID.java and things started work as it was before wrt deviceID.
imported android.os.Build to the file.
import android.os.Build;
and updated getDeviceId method as below
protected void getDeviceId(){ > _boolean isAndroid10 = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSIONCODES.Q; try { Context context = cordova.getActivity().getApplicationContext(); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String uuid; String androidID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); **_String deviceID; String simID;_** if ("9774d56d682e549c".equals(androidID) || androidID == null) { androidID = ""; } **_uuid = androidID;_** **_if ( !isAndroid10 ) { deviceID = tm.getDeviceId(); simID = tm.getSimSerialNumber(); if (deviceID == null) { deviceID = ""; } if (simID == null) { simID = ""; } uuid = androidID + deviceID + simID; }_** uuid = String.format("%32s", uuid).replace(' ', '0'); uuid = uuid.substring(0, 32); uuid = uuid.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"); this.callbackContext.success(uuid); }catch(Exception e ) { this.callbackContext.error("Exception occurred: ".concat(e.getMessage())); } }
see if it works for you. (you should remove and add the android platforms again once the plugin is updated with these changes)
@RameshSenagasetti I can confirm this is working. ~However two things to notes~
~1. getDeviceId is deprecated https://developer.android.com/reference/android/telephony/TelephonyManager#getDeviceId(int)
~let me know otherwise.~
UPDATE
Correction @RameshSenagasetti I see you are only using getDeviceId for everything lower than android 10 which is what is was doing before.
I was under the impression though that you need READ_PRIVILEGED_PHONE_STATE for Android 10 >= ??
This thread might be useful to the conversation to officially fix this plugin https://stackoverflow.com/questions/4799394/is-secure-android-id-unique-for-each-device
I am also getting this error. Any updates ?
Two of three data used to generate the uniqueId are now no more accessible for Android 10. They are :
See here
So I think the idea of @RameshSenagasetti to only use Secure.ANDROID_ID when the device version is equal or more than Android 10 is good.
But there will be some problem with devices being updated from Android 9 and less to 10 knowing that the generated ID will no more match
Exception occurred: getDeviceId: The user 10136 does not meet the requirements to access device identifiers.