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

return undefined #59

Open jeffersonmello opened 7 years ago

jeffersonmello commented 7 years ago

in my phone dual sim return undefined for all

`window.plugins.sim.getSimInfo(successCallback, errorCallback);

function successCallback(result) { console.log(result); } VM51:1 Uncaught ReferenceError: errorCallback is not defined(…)(anonymous function) @ VM51:1 function onDeviceReady() { window.plugins.sim.getSimInfo(successCallback, errorCallback); }

function successCallback(result) { console.log(result); }

function errorCallback(error) { console.log(error); } undefined function hasReadPermission() { window.plugins.sim.hasReadPermission(successCallback, errorCallback); } undefined function requestReadPermission() { window.plugins.sim.requestReadPermission(successCallback, errorCallback); } undefined // Android only: request permission function requestReadPermission() { window.plugins.sim.requestReadPermission(successCallback, errorCallback); }

function successCallback(result) { console.log(result); }

function errorCallback(error) { console.log(error); }

undefined`

jeffersonmello commented 7 years ago

i add permision, now return all excepted phonenumber

jasperltz93 commented 7 years ago

I have the same exact problem

jasperltz93 commented 7 years ago

I think I've figured out why by looking Johan's answer in this stackoverflow http://stackoverflow.com/questions/2480288/programmatically-obtain-the-phone-number-of-the-android-phone

jeffersonmello commented 7 years ago

I managed to resolve, need to add the following permission to android

And also need to grant permission by the user

function requestReadPermission() { window.plugins.sim.requestReadPermission(successCallback, errorCallback); }

Is working fine for min, the problem is phone number that is not returned, as I realized it something of the android itself

mexists commented 7 years ago

@jeffersonmello I'm using dual sim card too and I'm able to get the phoneNumber after entering the SIM card number at sim card setting.

Go to your phone setting -> SIM -> select your SIM card ->edit SIM card number

jeffersonmello commented 7 years ago

@mexists Interesting I'll test this method

BalaMC commented 6 years ago

I am using dual sim, not able to able to get the phone number, Anybody help me how to add permissions to get phone number from real device?