我一直在努力解决这个问题。在人们从弹出窗口按“呼叫”后,我正试图打电话。有趣的是,当他们点击电话号码时,它会直接拨打电话。但当他们点击“呼叫”时,控制台会返回:
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);
};
答案 0 :(得分:4)
可能为时已晚,但我想发表评论,以便其他用户无法面对此问题。 因为我在任何地方都找不到任何可行的解决方案。
您需要添加
config.xml中的<allow-navigation href="tel:*" />
我遇到了mailto intent的同样问题。当我直接尝试时它正在工作
<a onclick="mailto:test@me.com">Email</a>
但是当我尝试使用javascript window.location.href = 'mailto:test@me.com
internal navigation rejected - <allow-navigation> not set for url='mailto:test@me.com'
您只需在config.xml中添加allow-navigation
即可所以你的config.xml将是:
<access origin="mailto:*" launch-external="yes"/>
<allow-intent href="mailto:*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-navigation href="mailto:*" />
答案 1 :(得分:3)
我在config.xml中使用此配置 对于ios
<allow-navigation href="tel:*" />
for android
<allow-intent href="tel:*"/>
答案 2 :(得分:1)
在config.xml
中更改Cordova's WhiteListPlugin对我不起作用 - <access >,
`。我尝试了很多组合,包括上面那些组合。并不意味着这些不会起作用,只是为了我的设置它不会。 (适用于浏览器,Android和iOS的构建)
但是,使用Cordova InAppBrowser Plugin工作:
使用inAppBrowser插件并将目标设置为_system。
cordova.InAppBrowser.open('tel:123456789', '_system');
通过unsupported url
传递我在iOS中看到的问题,并启动本机系统的Web浏览器(即,不依赖于WhiteListPlugin来允许URL调用)。
希望这有帮助。
Cordova版本6.3.1。