我一直在爲此掙扎一段時間。我試圖在人們按下彈出窗口中的「呼叫」後撥打電話。有趣的是,它直接打電話時,他們點擊電話號碼。但是,當他們點擊 '呼叫',控制檯將返回:在科爾多瓦允許撥打電話(和地圖和郵件)
ERROR Internal navigation rejected - <allow-navigation> not set for url='tel:06-83237516
代碼:
控制器:
$scope.callPerson = function() {
var link = "tel:" + $scope.person.phonenumber;
var confirmTel = $ionicPopup.confirm({
title: $scope.person.phonenumber,
cancelText: 'Cancel',
okText: 'Call'
});
confirmTel.then(function(res) {
if (res) {
window.open(link);
} else {
console.log('cancel call');
}
});
}
的Config.xml:
<access origin="*"/>
<allow-intent href="tel:*"/>
<allow-intent href="mailto:*"/>
<access origin="tel:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
HTML:
<div ng-click="callPerson()"> {{person.phonenumber}}</div>
使用Mail,它根本不起作用,並返回相同的錯誤。 同樣用於打開地圖。它可以在PhoneGap測試應用程序中運行,但在部署時不會運行。
地圖代碼:
$scope.openmaps = function() {
var address = $scope.person.adres + ", " + $scope.person.plaats;
var url = '';
if (ionic.Platform === 'iOS' || ionic.Platform === 'iPhone' || navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
url = "http://maps.apple.com/maps?q=" + encodeURIComponent(address);
} else if (navigator.userAgent.match(/(Android|BlackBerry|IEMobile)/)) {
url = "geo:?q=" + encodeURIComponent(address);
} else {
url = "http://maps.google.com?q=" + encodeURIComponent(address);
}
window.open(url);
};
Try document.location.href ='tel:'+ $ scope.person.phonenumber; – Ved
這可能會奏效!但是,我發現了一些東西;向config.xml中添加並沒有訣竅(而是)。不知道這是爲什麼。也許是因爲我嘗試從控制器調用URL? –
Cake
對我來說它在android中工作正常,但在iOS中沒有任何幫助? –