简体   繁体   中英

Phonegap tel: uri not working on android even after whitelisting

html5 jquery mobile hybrid phonegap app on android s6 sport using phonegap desktop and phonegap developer app on phone. Not sure of phone gap version (cli not installed properly, tried but opening prompt gives an error) but it is a recent (last week) install.

Using call in chrome opens phone app dialer but not in test phonegap app - click does nothing. Also mailto: and http: acts the same, works in chrome not in app.

The exact html is:

<a id="btn_phone" href="tel:18001231234" rel="external" data-role="button" data-icon="phone"></a>

I added to the config.xml and based on comments removed the catch-all which got it working for others but not in my case.

In config file is this:

<access origin="tel:*" launch-external="yes"/>
<access origin="geo:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
<access origin="sms:*" launch-external="yes"/>
<plugin name="cordova-plugin-whitelist" version="1"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>

as stated I removed this:

<access origin="*"/>

So based on everything I've read that should be all I need to do but it is still not working.

Two questions:

  1. Does anyone know a fix for this?

  2. Is there a way to debug this on the phone to see what is failing?

thanks

I struggled with this forever and eventually did the following which worked:

In the HTML:

<input type="button" href="tel:+1-800-555-1234“ class="phone-number" value="1-800-555-1234"/>

In the Javascript:

$(‘.phone-number’).bind(click, function(e) {
    e.preventDefault()
    var phoneLink = $(e.currentTarget).attr('href');
    window.open(phoneLink, '_system', 'location=yes’);
}

What is your cordova version? I think your problem is the white list plugin declaration.

Try this:

<feature name="Whitelist">
    <param name="android-package" value="YOUR_WHITELIST_CORDOVA_PATH" />
    <param name="onload" value="true" />
</feature>

More info on how to configure White List here: https://www.npmjs.com/package/cordova-plugin-whitelist


NOTE TO ALL This answer does NOT work for CLI. <feature> in this context is meant for SDK and those using an IDE. See Documentation The feature Element
Quote:

If you use the CLI to build applications, you use the plugin command to enable device APIs. This does not modify the top-level config.xml file, so the <feature> element does not apply to your workflow.

If you work directly in an SDK and using the platform-specific config.xml file as source, you use the <feature> tag to enable device-level APIs and external plugins. They often appear with custom values in platform-specific config.xml files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM