pbakondy / cordova-plugin-sim

:cherries: A cordova plugin to get the device's SIM data (carrier name, mcc mnc, country code, telephonenumber, etc)
MIT License
163 stars 101 forks source link

The user 10412 does not meet the requirements to access device identifiers. #94

Open Polyscripts-Aashay opened 3 years ago

Polyscripts-Aashay commented 3 years ago

Android I have already given the permission but still not getting SIM info.

result: Unable to get sim info: The user 10412 does not meet the requirements to access device identifiers."

this.sim.getSimInfo().then(
  (info) => console.log('Sim info: ', info),
  (err) => console.log('Unable to get sim info: ', err)
);
hrpatidar commented 3 years ago

Getting the same for me. It mostly started coming after requesting permission. But without permission, not getting complete details of the sim.

dodysat commented 3 years ago

I also had the same problem on android 10

adrienbarral commented 3 years ago

I think this issue is linked to a new privacy policy on android 10. If I well understood, they restrict access to non resetable device property to applications that grant the READ_PRIVILEGED_PHONE_STATE permission. And this permission is only for System Applications.

There is more detail THERE

Methods that require this privilege are :

Build::getSerial()
TelephonyManager::getImei()
TelephonyManager::getDeviceId()
TelephonyManager::getMeid()
TelephonyManager::getSimSerialNumber()
TelephonyManager::getSubscriberId()

And in this plugin, getDeviceId, getSimSerialNumber and getDeviceId are used.

So I guess that with Android > 10, these informations will not be available for a non system application.

Ashclan commented 3 years ago

I think this issue is linked to a new privacy policy on android 10. If I well understood, they restrict access to non resetable device property to applications that grant the READ_PRIVILEGED_PHONE_STATE permission. And this permission is only for System Applications.

There is more detail THERE

Methods that require this privilege are :

Build::getSerial()
TelephonyManager::getImei()
TelephonyManager::getDeviceId()
TelephonyManager::getMeid()
TelephonyManager::getSimSerialNumber()
TelephonyManager::getSubscriberId()

And in this plugin, getDeviceId, getSimSerialNumber and getDeviceId are used.

So I guess that with Android > 10, these informations will not be available for a non system application.

what the solution for this?

adrienbarral commented 3 years ago

@Ashclan : For me the solution is to modify this plugin. The modification must check for android version. if version is > 10, then the plugin should not call methods that require privilege and return a JSON result without informations that can't be retrieved now.

Personally, I encounter this problem on a small application I do on my free time, so I didn't spent time on doing this patch. I just need the user phone number, and I prefer to add a small form asking user to enter it's phone number rather than modifying this plugin... I don't really like to do Java on my freetime (even a little bit !) :smile: