9

I am trying to launch the phone dialer in my worklight 6.2 hybrid application when clicking on a button and/or an anchor tag. Below is the code I am using.

button:

<button onClick='window.parent.location.href = "tel:+1xxxx"'>Tel</button>

anchor tag:

<a href='tel:+18001111111' class="ui-link">(800) 111-1111</a>  

When we click on button/anchor tag below is the behavior in android and iOS.
In android:

Displays a pop up window with the message

Application Error net::ERR_UNKNOWN_URL_SCHEME (TEL:+18001111111)

In iOS:

The click event doesn't respond.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
user3878988
  • 761
  • 3
  • 8
  • 20

3 Answers3

34

Are you testing in the iOS Simulator? if so, you must test in a device.
For Android, you can test in either the Emulator or a device.

The following worked for me in an iOS device:

  • <a href="tel:+1-800-555-1234">call this number</a>
    Can be invoked right from the HTML

  • document.location.href = "tel:+375292771265";
    Can be invoked via a function on button tap

As for Android,

Due to security bugs in Cordova (and the fixes made to counter them), to get the above code to work, you need to open native\res\xml\config.xml and perform the following:

 - <access origin="*"/>
 + <access origin="tel:*" launch-external="true"/>
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • It works fine as a standalone html5 application, but when I use worklight 6.2 version it is not working. I also works in phonegap application. – user3878988 Aug 04 '14 at 16:43
  • I tested the above in a blank new Worklight 6.2 app. It works fine for me in iOS; did not try in Android. Investigate using the above, if it still does not work for you - provide a demo Worklight project showing how it is not working for you. – Idan Adar Aug 04 '14 at 16:46
  • Its my mistake. Till now I am testing in iOS simulator thats why it is not responding. I will test the application in iOS device soon. But when I test the same in android emulator and in device the issue is same. Could you please test your sample application in android device or emulator. Hope that will help me. – user3878988 Aug 04 '14 at 18:55
  • Thanks, may I know the approximate time to fix this. – user3878988 Aug 05 '14 at 23:56
  • Can you provide the complete WL Studio version? You can get it from installed software list in eclipse. Need this info for problem investigation. – jayakarthik Aug 07 '14 at 07:01
  • As a work around solution I am using window.open("tel:+18xxxx","_system") to open phone dialer. However if I use this there are couple other issues in my application I am working on it. – user3878988 Aug 07 '14 at 11:47
  • My WL version is 6.2.0.00-20140719-1643 – user3878988 Aug 07 '14 at 11:48
  • @user3878988, no need for a PMR - see my updated answer for a resolution. – Idan Adar Aug 12 '14 at 16:03
  • @IdanAdar, You mean I have to add '' in the next line to '' in config.xml. If so I made this change but still it is not working in android emulator. I didnot tested in device. Please let me know if any other changes required. – user3878988 Aug 15 '14 at 13:59
  • I mean remove the first and add the second. – Idan Adar Aug 15 '14 at 14:00
  • Hi Idan, I am getting the same error on my android application. Worklight version is 6.1.0.2 Interim Fix - 6.1.0.01.20140922-2007. Applied the CALL_PHONE permission in android manifest file and also updated the as you specified. – Ragu Oct 09 '14 at 15:35
  • Read the blog post linked in the answer. – Idan Adar Oct 09 '14 at 15:36
  • Yapp, Seen that article and applied the suggested fixes. Only difference i can see is my Worklight Version, i have even latest fix pack that has been release to support iOS on 09/23/2014. Worklight version is 6.1.0.2 Interim Fix - 6.1.0.01.20140922-2007. Still getting the same error. – Ragu Oct 09 '14 at 16:03
  • Hi Idan. I could see this CordovaUriHelper.class file in the cordova.jar. Created PMR for the same. Keep you posted. – Ragu Oct 09 '14 at 16:48
  • I wanted to open in it InAppBrowser because it is a part of some page which I open in the inappbrowser. Example : var ref = cordova.InAppBrowser.open("tel:4693058987", '_blank'); but it gives the ERR_UNKNOWN_URL_SCHEME error. How can I make it work? – Vishwani Mar 26 '15 at 21:22
  • We had '' in config.xml. It only worked once we removed: . – Carl Prehn Apr 29 '15 at 00:43
1

this cordova plugin are use

mx.ferreyra.callnumber 0.0.2 "Cordova Call Number Plugin"

Code

   <ion-fab left bottom>
    <a href="tel:number" class="button" ion-fab color="light">
        <ion-icon name="keypad"></ion-icon>
    </a>
</ion-fab>
0

If you are using like this <a href="tel:+1-800-555-1234">call this number</a> and you still getting an error saying ERR_UNKNOWN_URL_SCHEME then use cordova-plugin-invokedialer.

cordova-plugin-invokedialer- npm

Navnath Adsul
  • 364
  • 3
  • 10