1
I have a problem, I know because of how javascript works, but I do not know how to solve the problem.
I’m using Cordova and a function need to use the Phone permission on Android.
So before executing the method I check if permission has been granted, if I do not ask permission.
the problem is that it does not wait for the return and the value always stays as Undefined.
Follows the code
var getImeiNumeber = function()
{
if (hasReadPermission() !== true){
requestReadPermission();
getImeiNumeber();
} else if (hasReadPermission() === false) {
window.plugins.sim.getSimInfo(successCallback, errorCallback);
}
}
The function
var successCallback = function(result)
{
console.log(result);
return result;
}
var errorCallback = function(error)
{
console.log(error);
}
// Android only: check permission
var hasReadPermission = function()
{
window.plugins.sim.hasReadPermission(successCallback, errorCallback);
}
// Android only: request permission
var requestReadPermission = function()
{
window.plugins.sim.requestReadPermission(successCallback, errorCallback);
}
Perfect thank you very much
– Jefferson Mello Olynyki