IONIC / cordova,在IOS拨打电话 [英] IONIC/cordova, make phone call in IOS
问题描述
我在这个主题上找到了一个关于离线的线索: http://forum.ionicframework.com/t/making-phone-call-from-app-href-tel-123/1968/11 。
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.
它提到了白名单插件:
https://github.com/apache/cordova-plugin-whitelist
It mentions the whitelist plugin: https://github.com/apache/cordova-plugin-whitelist
所以我尝试在config.xml中添加这些代码,但它仍然无法正常工作。
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>
错误:
2015-07-03 00:21:16.231 myParking [27167:1006045]无法加载
网页,但显示错误:无法显示网址
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);
}
错误:
2015-07-03 00:24:09.620 myParking [27308:1007392]失败
2015-07-03 00:24:09.620 myParking[27308:1007392] fail
那么我怎样才能做到这一点呢?
So how can I make this work?
离子版本: 1.4.3
cordova版本: 5.0.0
推荐答案
我已经解决了这个问题。在我的环境中(离子版:1.4.3 cordova版本:5.0.0),我不需要像ozhanli所提到的那样添加任何插件或修改配置文件。该指令可以按预期工作。那我为什么问这个问题呢?因为我在模拟器中测试我的程序,它不支持电话,消息等。将程序部署到物理设备后,该指令有效。
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.
因此,如果您想在IONIC中拨打电话(离子版本:1.4.3 cordova版本:5.0 .0),只需添加此代码即可使用:
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.
这篇关于IONIC / cordova,在IOS拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!