initiate a call by clicking button on ionic app
Solution 1
You need to put this in your config.xml
file for the href tel:phonenumber
to work
<access origin="tel:*" launch-external="yes" />
Solution 2
Using a href="tel:+1-1800-555-5555 " will not work as you want, add this plugin to your project by running command
cordova plugin add https://github.com/Rohfosho/CordovaCallNumberPlugin.git
and in your project use this line to make call
window.plugins.CallNumber.callNumber(onSuccess, onError, number);
onSuccess
and onError
are callback functions, so declare them also.
Note: If you have skype installed, it will ask you to either make call from skype or direct phone. Otherwise it will directly start call.
Full JS Code:
$scope.CallNumber = function(){
var number = '18002005555' ;
window.plugins.CallNumber.callNumber(function(){
//success logic goes here
}, function(){
//error logic goes here
}, number)
};
Mohit H
Updated on August 25, 2022Comments
-
Mohit H over 1 year
i was using a href="tel:+1-1800-555-5555 " Call me" to call , but it is not initiating the call directly rather than putting the number in the box / asking for confirmation ..can i call directly , as if we click "Call Me" and the call gets started, i am using ionic + angular do i have to include cordova , have checked this articale but not much help:
http://rickluna.com/wp/2012/02/making-a-phone-call-from-within-phonegap-in-android-and-ios/