Skip to content Skip to sidebar Skip to footer

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. H

Solution 1:

If you want to do it through html, then you just have to place a tag like this:

<ahref="tel:XXXXXXXXXX">Call me!</a>

similarly if you wanna do it through javascript, you can do:

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

Solution 2:

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

Solution 3:

You probably just can't, when your APP is running from mobile browser. You'll need to wrap your app as cordova app or similar. Then you can for example use PhoneGap-PhoneDialer

Solution 4:

You can try with below one,

window.location.href = "tel:+91123456789";

But, for IOS it may not work because of some permission issues. In that case you can try like below,

window.open('tel:+91123456789', '_system');

Solution 5:

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.

Post a Comment for "Is It Possible To Programmatically Call A Telephone Number In Js?"