I'm new to mobile development. I'm using PhoneGap and I want to add a feature in my app to get the phone number from the SIM card, both on iOS and Android. I'm using this plugin:
I'm using this very simple index code to display whatever information I can retrieve from the plugin.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SIM</title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady(){
window.plugins.sim.getSimInfo(successCallback, errorCallback);
}
function successCallback(result) {
document.getElementById("simInfo").innerHTML=JSON.stringify(result);
}
function errorCallback(error) {
document.getElementById("simInfo").innerHTML=JSON.stringify(result);
}
</script>
</head>
<body>
<p id="simInfo"></p>
</body>
</html>
This does not display anything. Is there anything I'm doing wrong or missing?
I found this ::
I did some changes in code but I got "undefined" message.
I attached the result image please check this.
please check this. Thanks.
Are you testing on iOS or Android? On Android 6.0 and above you need to implement.
Also looking at your code. In the errorCallback function, result will be undefined.
You need to change this.
To this
It gets numbers saved by user as phone number of the sim. If nothing is saved, it will be empty string. I am using redmi note 3. It is there in settings->sim cards & mobile networks->sim1/2->Edit sim card number