-1
I need to get my phone number back and I got it with Cordova, I tried some plugins but on my device that I am testing did not work any
my device is dual yes and android 7.1
there is some way to recover the phone number and Imei in both cases ?
-1
I need to get my phone number back and I got it with Cordova, I tried some plugins but on my device that I am testing did not work any
my device is dual yes and android 7.1
there is some way to recover the phone number and Imei in both cases ?
0
As requested, the phone number could not recover because sometimes returns null, but the of Imei is there:
plugin: https://github.com/pbakondy/cordova-plugin-sim
function errorCallback(error)
{
console.log(error);
}
// Android only: check permission
function hasReadPermission()
{
window.plugins.sim.hasReadPermission(successCallback, errorCallback);
}
// Android only: request permission
function requestReadPermission()
{
window.plugins.sim.requestReadPermission(successCallback, errorCallback);
}
function retImei(callback){
window.plugins.sim.hasReadPermission(
function isAlowed(alowed){
if (alowed != true) {
window.plugins.sim.requestReadPermission(
function returnedAlowed(returned){
if (returned === 'OK'){
window.plugins.sim.getSimInfo(
function getResponse(response){
callback(response.deviceId);
},
errorCallback
);
} else {
throwError('É necessário permitir acesso ao telefone');
}
},
errorCallback
);
} else {
window.plugins.sim.getSimInfo(
function getResponse(response){
callback(response.deviceId);
},
errorCallback
);
}
}, errorCallback);
}
function getImei(){
retImei(function returnImei(returned){
myApp.alert(returned);
})
}
Browser other questions tagged android ios apache-cordova cordova-plugin
You are not signed in. Login or sign up in order to post.
Didn’t work, what? Are you trying to say that there was an exception or something else? Which plugins tried?
– Guilherme Nascimento
Undefined returns, I am currently tetando with this Cordova-plugin-yes
– Jefferson Mello Olynyki
How is your code that returns this error?
– Randrade
window.plugins.sim.getSimInfo(successCallback, errorCallback);
– Jefferson Mello Olynyki
tried this too and always caia error https://github.com/vliesaputra/DeviceInformationPlugin var deviceInfo = Cordova.require("Cordova/plugin/Deviceinformation"); deviceInfo.get(Function(result) { console.log("result = " + result); }, Function() { console.log("error"); });
– Jefferson Mello Olynyki
and this https://github.com/aquto/cordova-plugin-imei ?
– Guilherme Nascimento
this one still won’t take a look, thanks for while
– Jefferson Mello Olynyki
So I asked myself about that just now, I added here but not wanting to compile
– Jefferson Mello Olynyki
error in xml config, I think I added the permission wrong... can tell me how to add correctly, according to Plugi the permission is READ_PHONE_STATE
– Jefferson Mello Olynyki
can friend, <Feature name="Networkstatus"> <param name="android-package" value="Cdvconnection" /> </Feature>
– Jefferson Mello Olynyki
Opa, posted as response, will help a lot of people, and post an example of how to install the plugin too ;)
– Guilherme Nascimento
I will do this, but first I want to see fully functional, the plugin returned several information except phone number, I’m seeing if you have any specific method but it seems that not
– Jefferson Mello Olynyki
If possible, please post the answer to how you did
– Anderson Brunel Modolon