Allow calling (both cards and mail) in cordova

I struggled with this for a while. I try to call when people click "Call" from a popup. It's funny that he immediately calls when he dials a phone number. But when they click "Call", the console returns:

ERROR Internal navigation rejected - <allow-navigation> not set for url='tel:06-83237516

code:

Controller:

$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>  

It does not work with Mail at all and returns an identical error. The same goes for opening cards. It works in a PhoneGap test application, but not during deployment.

Card Code:

$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);
};
+4
source share
3 answers

, , , . .

<allow-navigation href="tel:*" /> config.xml

mailto. , .

<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

, config.xml :

<access origin="mailto:*" launch-external="yes"/>    
<allow-intent href="mailto:*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-navigation href="mailto:*" />
+4

config.xml ios

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

android

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

WhiteListPlugin config.xml - <access >,`. , . , , . ( , Android iOS)

However, using the Cordova InAppBrowser plugin , it worked:

Use the inAppBrowser plugin and set the target to _system. cordova.InAppBrowser.open('tel:123456789', '_system');

This conveys the problems that I saw in iOS using unsupported url, and launches the system’s own web browser (i.e. does not rely on WhiteListPlugin to allow the url to be called).

Hope this helps.

Cordoba version 6.3.1.

+1
source

Source: https://habr.com/ru/post/1627520/


All Articles