I have found a thread in ionic on this topic: http://forum.ionicframework.com/t/making-phone-call-from-app-href-tel-123/1968/11.
It mentions the whitelist plugin: https://github.com/apache/cordova-plugin-whitelist
So I try to add these code in the config.xml, but it still can not work.
<access origin="tel:*" launch-external="yes" />
<access origin="mailto:*" launch-external="yes" >
<allow-intent href="tel:*" />
HTML:
<a href="tel: 110">call</a>
Error:
2015-07-03 00:21:16.231 myParking[27167:1006045] Failed to load webpage with error: The URL can’t be shown
I try to use another plugin, but it still can not work.
https://github.com/Rohfosho/CordovaCallNumberPlugin
HTML:
<span ng-click="onDail($index)">call</span>
JS:
var onSuccess = function(){
console.log("success");
}
var onError = function(){
console.log("fail");
}
$scope.onDail = function(index){
window.plugins.CallNumber.callNumber(onSuccess, onError, $scope.ParkingRecords[index].number);
}
Error:
2015-07-03 00:24:09.620 myParking[27308:1007392] fail
So how can I make this work?
ionic version: 1.4.3 cordova version: 5.0.0
I try it in a
tag it worked on android:
First add cordova-plugin-whitelist
cordova add plugin cordova-plugin-whitelist
Then add following lines in config.xml
<access origin="tel:*" launch-external="yes" />
<allow-intent href="tel:*" />
Finally in a
tag use line below
<a href="tel:555 555 5555" target="_blank">
<i class="fa fa-phone"></i>
</a>
I have resolved this issue. In my environment(ionic version: 1.4.3 cordova version: 5.0.0), I don't need to add any Plugin or revising the configuration file as ozhanli mentioned. The directive can work as expected. So why I ask this problem? Because I test my program in the simulator, which doesn't support the phone call, message and so on. After deploying my program to a physical device, the directive works.
So if you want to make a phone call in IONIC(ionic version: 1.4.3 cordova version: 5.0.0) , just add this code to make it work:
<a href="tel: 110">call</a>
Notice: Test it in physical device, not in simulator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With