How to use Rohfosho/CordovaCallNumberPlugin

2.3k views Asked by At

How to use this plugin with onSuccess and onError function my code is this:

 $scope.callNumber= function (){

           var number = 3333322456;
           var onSuccess=function(number){

               alert("invia messaggio");
           };

           function onError(error) {
                alert('code: '    + error.code    + '\n' +
                      'message: ' + error.message + '\n');
            }

           window.plugins.CallNumber.callNumber(onSuccess, onError, number);

       }

but it doesn't work.

2

There are 2 answers

1
Francesco Mirabelli On

Follow this tutorial. It helps me http://rickluna.com/wp/2012/02/making-a-phone-call-from-within-phonegap-in-android-and-ios/

But it's not about this plugin. it's a different way to call immediately via cordova.

0
fanbondi On

I was able to make it work using the code below.

function onSuccess(result){
  console.log("Success:"+result);
}

function onError(result) {
 console.log("Error:"+result);
}

$scope.callNumber = function(number){
  console.log("Launching Calling Service for number "+number);
  window.plugins.CallNumber.callNumber(onSuccess, onError, number, false);
}

I attached this to my html element as follows.

<button class="button icon ion-ios-telephone" ng-click="callNumber(0123456789)">Call</button>