Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to programmatically call a telephone number in JS?

So basically right now I can create a button with an A tag that has an href="tel:XXXXXXXXXXX" and if a user clicks / taps on that it will bring them into their phone application. However I am trying to do this programmatically on gesture recognition (swipe). The gesture is working, so far I have tried window.location = "tel:XXXXXXXXXX"; window.open('tel:XXXXXXXXXX', '_top');

neither of which have worked yet. Any idea? Ionic / Angular 1

Note** It appears to only happen on iOS, Android seems to be working fine.

like image 557
CMOS Avatar asked Oct 30 '16 20:10

CMOS


2 Answers

Try it on a real device.

None of these methods worked on the IOS emulator. It only worked on a physical device. That tripped me up for a while.

like image 100
Zane Avatar answered Sep 29 '22 00:09

Zane


For this you will require to add this in the config.xml first

<access origin="tel:*" launch-external="yes" />

then call it like:

document.location.href = "tel:XXXXXXXXXX";

Whitelist Guide

like image 25
Siraj Hussain Avatar answered Sep 29 '22 01:09

Siraj Hussain