我在这个主题上发现了一个关于离线的主题:http://forum.ionicframework.com/t/making-phone-call-from-app-href-tel-123/1968/11.
它提到了白名单插件:https: //github.com/apache/cordova-plugin-whitelist
所以我尝试在config.xml中添加这些代码,但它仍然无法正常工作.
<access origin="tel:*" launch-external="yes" />
<access origin="mailto:*" launch-external="yes" >
<allow-intent href="tel:*" />
Run Code Online (Sandbox Code Playgroud)
HTML:
<a href="tel: 110">call</a>
Run Code Online (Sandbox Code Playgroud)
错误:
2015-07-03 00:21:16.231 myParking [27167:1006045]无法加载网页并显示错误:无法显示网址
我尝试使用另一个插件,但它仍然无法正常工作.
https://github.com/Rohfosho/CordovaCallNumberPlugin
HTML:
<span ng-click="onDail($index)">call</span>
Run Code Online (Sandbox Code Playgroud)
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);
}
Run Code Online (Sandbox Code Playgroud)
错误:
2015-07-03 00:24:09.620 myParking [27308:1007392]失败
那我怎么能做这个呢?
离子版:1.4.3 cordova版本:5.0.0
小智 12
我在a标签上尝试它在android上工作:
首先添加cordova-plugin-whitelist
cordova add plugin cordova-plugin-whitelist
Run Code Online (Sandbox Code Playgroud)
然后在config.xml中添加以下行
<access origin="tel:*" launch-external="yes" />
<allow-intent href="tel:*" />
Run Code Online (Sandbox Code Playgroud)
最后在a下面的标签使用行中
<a href="tel:555 555 5555" target="_blank">
<i class="fa fa-phone"></i>
</a>
Run Code Online (Sandbox Code Playgroud)
我已经解决了这个问题.在我的环境中(离子版:1.4.3 cordova版本:5.0.0),我不需要像ozhanli所提到的那样添加任何插件或修改配置文件.该指令可以按预期工作.那我为什么问这个问题呢?因为我在模拟器中测试我的程序,它不支持电话,消息等.将程序部署到物理设备后,该指令可以正常工作.
因此,如果您想在IONIC(离子版:1.4.3 cordova版本:5.0.0)中拨打电话,只需添加此代码即可使其正常工作:
<a href="tel: 110">call</a>
Run Code Online (Sandbox Code Playgroud)
注意:在物理设备中测试,而不是在模拟器中测试.
| 归档时间: |
|
| 查看次数: |
12795 次 |
| 最近记录: |