0

I'm working in a windows 7 environment using Cordova 6.4.0 to assemble a Android 6.1.0 app, and links in the app to send a call or email are not working. The app builds on my desktop, and the links work in Chrome. I am testing by loading the app using ADB 1.0.36 to my Galaxy S7.

I have the whitelist and inappbrowser plugins installed, and added the and in my config.xml as you see below. Slight changes were done to mask company information.

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.test.app" version="3.0" android-versionCode="3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>AppName</name>
    <description>
        App Description
    </description>
    <author email="email@company.com" href="https://www.example.com">
        Author Name
    </author>
    <content src="index.html" />
    <access launch-external="yes" origin="tel:*" />
    <access launch-external="yes" origin="mailto:*" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="android-minSdkVersion" value="14"/>
    <platform name="android">
        <icon density="ldpi" src="assets/icons/android/ldpi.png" />
        <icon density="mdpi" src="assets/icons/android/mdpi.png" />
        <icon density="hdpi" src="assets/icons/android/hdpi.png" />
        <icon density="xhdpi" src="assets/icons/android/xhdpi.png" />
        <icon density="xxhdpi" src="assets/icons/android/xxhdpi.png" />
        <icon density="xxxhdpi" src="assets/icons/android/xxxhdpi.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="~1.3.0" />
    <engine name="android" spec="~6.1.0" />
</widget>

Here's an example of the links that are not working.

<div class="cuboxes">
    <h2>Group list</h2>
    <h3>( <span>800.555.5555</span> )</h3>
    <a href="tel:1-800-555-5555" class="cu green hidetablet">Call Us</a>
    <a href="mailto:mailto:person@example.com?Subject=Email From the App" class="cu green email">E-Mail Us</a>
</div>

I've tried changing the phone number format (removing the "-" or adding a "+" at the start of the number), and a number of other configuration changes. This app was built from scratch, and the web pages were added from the previous version of the app. The old version does not build as it does not use gradle.

Any help would be appreciated.

Surya Prakash Kushawah
  • 3,185
  • 1
  • 22
  • 42
MikeL
  • 79
  • 2
  • 12

2 Answers2

1

tel: phone_number
Calls the entered phone number. Valid telephone numbers as defined in the IETF RFC 3966 are accepted. Valid examples include the following:

* tel:2125551212
* tel: (212) 555 1212

The Android browser uses the Phone app to handle the “tel” scheme, as defined by RFC 3966.
Clicking a link like:

<a href="tel:2125551212">2125551212</a>

on Android will bring up the Phone app and pre-enter the digits for 2125551212 without autodialing.

Have a look to RFC3966

UPDATE

see tel link android not working (Galaxy S5)

It seems you need to add a permission, do you have this set?

<access origin="tel:*" launch-external="yes" /> in your config.xml?

UPDATE 2

see “tel”, “sms”, and “mailto” no longer working in Android after upgrading to cordova 3.6.3

 1. Add InAppBrowser plugin

**cordova plugin add org.apache.cordova.inappbrowser** 
  1. Create custom function in your JS file to open special links within the InApp browser

    var app = {
            initialize: function() {
            this.bindEvents();
        },         
        bindEvents: function() {
            document.addEventListener('deviceready', this.onDeviceReady, false);
        },         
        onDeviceReady: function() {
            app.receivedEvent('deviceready');
        },
        openNativeAppWindow: function(data) {
            window.open(data, '_system');
        }
    

    };

  2. The place where you are invoking special links like sms or tel then pass on your custom url with data and let it open the native browser window which in turn will push the native App to handle the special urls.

Few example:

<br><br><input type="button" onClick="app.openNativeAppWindow('http://google.com')" value="Open Google"/>
            <br><br><a onClick="app.openNativeAppWindow('geo://0,0?q=dallas')" data-rel="external">google maps</a>
            <br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=Bacau')">Geolocation Test</a>
            <br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=34.99,-106.61(Treasure)')">longitude & latitude with a string label</a>
            <br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=1600+Amphitheatre+Parkway%2C+CA')">street address Test</a>
            <br><br><a onClick="app.openNativeAppWindow('sms:2125551212')">SMS</a>
            <br><br><a onClick="app.openNativeAppWindow('mms:2125551212')">MMS</a>
            <br><br><a onClick="app.openNativeAppWindow('tel:2125551212')">Open Phone Dialer</a>
Community
  • 1
  • 1
jdmdevdotnet
  • 1
  • 2
  • 19
  • 50
  • Thank you, but at the bottom of the original post, I stated I tried removing the dashes with no effect. I tried it also with the suggestion of Luca's, but it did not work. – MikeL Dec 02 '16 at 17:04
  • So what is the error? Any debug information? What happens? Might be useful to provide something other than 'it doesn't work'. There must be something going on with your syntax, this `should` work. – jdmdevdotnet Dec 02 '16 at 17:22
  • The tel href link does not respond when selected in the app. That is what I mean by no effect. There is no error message like with Luca's suggestion. I agree that this should work, which is why I posted here to see what I might have missed. – MikeL Dec 02 '16 at 17:34
  • Right, not attacking you just trying to understand. By 'no error message' do you mean no errors in console? – jdmdevdotnet Dec 02 '16 at 17:35
  • I do not add inflection if I do not hear a voice, so no attack was perceived. I wasn't sure what you meant by error in the console, so I did some reading. You just taught me I can see my device on my computer using Chrome developer tools. The console does not return an error. – MikeL Dec 02 '16 at 17:51
  • Well there's also an output that would display errors as well. One thing that I did notice was you're using `1800xxxxxxx` where my example was `xxxxxxxxx` (without the prefixed `1`). Can you try a different number like that and see if it works? It's possible it's an Android bug, and you can't do that with a prefixed `1`. Worth a try at least. – jdmdevdotnet Dec 02 '16 at 17:57
  • I tried both removing the 1 and using a different 10 digit phone number. Both did not give a response. Also from your updated answer, that is already on line 11 of the config.xml file. – MikeL Dec 02 '16 at 18:12
  • Nope. Both are unresponsive when clicked. I checked the source in the Developer tools to make sure the links were not being modified for some reason after building the app. – MikeL Dec 02 '16 at 18:23
  • See updated answer. Clearly seems like a syntax issue of some sort on your part. However, there's another way to handle it if you want to take a look at both my updated answer and the link I provided. – jdmdevdotnet Dec 02 '16 at 18:26
  • Adding the JS, while not the solution I was looking for, got the tel and mailto links working. I'll mark this as answered. – MikeL Dec 05 '16 at 18:43
0

Try with this: "tel://" and "mailto://"

Luca Nicoletti
  • 2,265
  • 2
  • 18
  • 32
  • Add that causes the phone to show a popup saying "Error Loading Page", and the email throws an Application error and crashes the app. "There was a network error. (file:///android_asset/www/mailto//:person@example.com?Subject=Email From the App) – MikeL Dec 02 '16 at 17:01