簡體   English   中英

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

它提到了白名單插件: 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:*" />

HTML

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

錯誤

2015-07-03 00:21:16.231 myParking [27167:1006045]無法加載網頁並顯示錯誤:無法顯示網址

我嘗試使用另一個插件,但它仍然無法正常工作。

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]失敗

那我怎么能做這個呢?

離子版: 1.4.3 cordova版本: 5.0.0

我在android上運行a標簽中嘗試它:

首先添加cordova-plugin-whitelist

cordova add plugin cordova-plugin-whitelist

然后在config.xml中添加以下行

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

最后在下面a標簽使用行中

<a href="tel:555 555 5555" target="_blank">
    <i class="fa fa-phone"></i>
</a>

我已經解決了這個問題。 在我的環境中(離子版:1.4.3 cordova版本:5.0.0),我不需要像ozhanli所提到的那樣添加任何插件或修改配置文件。 該指令可以按預期工作。 那我為什么問這個問題呢? 因為我在模擬器中測試我的程序,它不支持電話,消息等。 將程序部署到物理設備后,該指令可以正常工作。

因此,如果您想在IONIC(離子版:1.4.3 cordova版本:5.0.0)中撥打電話,只需添加此代碼即可使其正常工作:

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

注意:在物理設備中測試,而不是在模擬器中測試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM