简体   繁体   English

IONIC / cordova,在IOS拨打电话

[英]IONIC/cordova, make phone call in IOS

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 . 我在这个主题上发现了一个关于离线的主题: 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 它提到了白名单插件: https//github.com/apache/cordova-plugin-whitelist

So I try to add these code in the config.xml, but it still can not work. 所以我尝试在config.xml中添加这些代码,但它仍然无法正常工作。

<access origin="tel:*" launch-external="yes" />
<access origin="mailto:*" launch-external="yes" >

<allow-intent href="tel:*" />

HTML : 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 2015-07-03 00:21:16.231 myParking [27167:1006045]无法加载网页并显示错误:无法显示网址

I try to use another plugin, but it still can not work. 我尝试使用另一个插件,但它仍然无法正常工作。

https://github.com/Rohfosho/CordovaCallNumberPlugin https://github.com/Rohfosho/CordovaCallNumberPlugin

HTML : HTML

<span ng-click="onDail($index)">call</span>

JS : 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 2015-07-03 00:24:09.620 myParking [27308:1007392]失败

So how can I make this work? 那我怎么能做这个呢?

ionic version: 1.4.3 cordova version: 5.0.0 离子版: 1.4.3 cordova版本: 5.0.0

I try it in a tag it worked on android: 我在android上运行a标签中尝试它:

First add cordova-plugin-whitelist 首先添加cordova-plugin-whitelist

cordova add plugin cordova-plugin-whitelist

Then add following lines in config.xml 然后在config.xml中添加以下行

<access origin="tel:*" launch-external="yes" />
<allow-intent href="tel:*" />

Finally in a tag use line below 最后在下面a标签使用行中

<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. 在我的环境中(离子版:1.4.3 cordova版本:5.0.0),我不需要像ozhanli所提到的那样添加任何插件或修改配置文件。 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: 因此,如果您想在IONIC(离子版:1.4.3 cordova版本:5.0.0)中拨打电话,只需添加此代码即可使其正常工作:

<a href="tel: 110">call</a>

Notice: Test it in physical device, not in simulator. 注意:在物理设备中测试,而不是在模拟器中测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM