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

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.

If you want to do it through html, then you just have to place a tag like this:
Call me!
similarly if you wanna do it through javascript, you can do:
document.location.href = "tel:XXXXXXXXXX";

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

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

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');

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.

Related

How to hide URL Bar in Ionic 5 Capacitor using Browser Plugin?

Checking the new Ionic Capacitor Docs, there seems NO OPTION to hide the url bar of the Browser Plugin (Previously InAppBrowser) at the moment. Need help please.
According to this discussion on a GitHub Issue thread, this is not going to be possible due to the fact that both the IAB and Browser plugins use SFSafariViewController, which doesn't allow you to hide the native controls.
That said, this has been driving me crazy for a while now, as I can't hide the URL bar in either OS even when using the original IAB.
I use iframe to solve the problem
<iframe src='https://stackoverflow.com/' />
ps: url use https

SMS Link Not Working for Hangouts on Android

The following SMS link does not seem to work on a Nexus in Hangouts, but works fine in the default Messaging app on a Samsung phone.
Link
I even tried adding a number before the URL, but no luck:
Link
Any idea how I can fix this?
It should be ? instead of & since it's the first parameter. Tested it over my nexus and it worked correctly after this fix (I'm using Google Messenger App).
Link
UPDATE:
Another problem that you may have is that Hangouts doesn't support pre-populated sms message links.
Also, looks like you should use & for iOS devices.
How to pre-populate the sms body text via an html link

JQuery Mobile app, make a mobile call with HTML 5

I am using JQuery Mobile with Phonegap and I am trying to create a button and when I click it a phone call should be made. I have mad a lot of research for this problem and I have found the following solution
Call
or
Call
This solution is working on browsers (is asking me to open Skype) but when I run it on Android with a Samsung Galaxy S2 is not working. It is not doing anything.
I have tried to add to the config.xml file the following permission:
<access launch-external="yes" origin="tel:*" />
but is not working either.
If you have any solution to suggest please do so. Thank you!
if you are using inappBrowser plugin, you can launch an inappbrowser window with the tel: address :
var refcall = window.open('tel:'+phoneno, '_blank', 'location=no,closebuttoncaption=Home,disallowoverscroll=yes');
you might then notice that when the call ends, you are taken back to a white screen with the tel number written on top. to avoid this, append the below code too :
refcall.addEventListener('loadstop', function(event) {
console.log('done initiating call... closing inappbrowser module');
refcall.close();
});
Try and let us know. It worked fine for me.
have you tried ?
<a rel="external" href="tel:+123456789">Call</a>
CordovaCallNumberPlugin should help you
https://github.com/rohfosho/CordovaCallNumberPlugin
add the following line to config.xml
<gap:plugin name="org.apache.cordova.inappbrowser" version="0.5.2" />
and use this command to dail the number:
window.open('tel:+123456789', '_system');
First of all, all the above answers you posted are correct and working fine. The problem I had, was that I was not including the cordova library in my app.
<script type="text/javascript" src="cordova.js"></script>
So when I have included the above line in the header of the page the phonenumber appeared on the Dial Screen! I am using the following code to create the call button:
<a rel="external" href="#" onclick="window.open('tel:+123456789', '_system');" data-role="button">Call</a>
I have tracked down the solution by creating a new phonegap app and use only the anchor tag given above. The cordova library was in the script by default.
Thank you for your answers

Opening safari webpage from Cordova app

I'm working on an APP that consist of HTML and CSS using the Cordova framework.
There is a button that should open a webpage. The problem is that it opens the webpage inside of the app instead of safari.
My knowledge of Objective C is extremely limited (none) so I was hoping there would be a solution using maybe Javascript.
I've looked all over the internet but couldn't find a non-Objective C solution.
The button is pretty straightforward: <img src="img/button.jpg" alt="website">
I thought target="_blank" might do something for me but that (unsurprisingly) didn't work.
You can use inappbrowser plugin
http://cordova.apache.org/docs/en/3.3.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser
Detect click on link using javascript or jquery and use this following code
window.open('http://www.google.com', '_system', 'location=yes');
I found the answer to my problem:
Opening all URL's with Cordova childbrowser
Only problem is that it automatically opens twitter.com because of the share button for some unknown reason. I'm guessing this is because of an api call it's performing upon being loaded.

Simple dashboard application

I am trying to have some fun with dashboard widgets, so I tried a simple application :
There will be a button over the widget which when clicked will open
StackOverflow website in safari.
To implement it, I tried this:
Created a custom dashboard widget.
Added a button to it from library.
Associated gotoStackOverflow handler with onclick event.
in body of function gotoStackOverflow, I wrote this code:
window.open('https://stackoverflow.com/','Stackoverflow','width=400, height=300');
When I 'Run' the application I found no browser window appearing on click of the button.
Can anyone suggest me where I may be wrong or/ and some useful links to play with dashcode and dashboard widgets?
Your code runs fine, when I recreate it. Maybe you have pop-ups blocked in Safari?
have you added
<key>AllowNetworkAccess</key>
<true/>
to the plist? if not the outside world will not be available.
I have used following code to solve my problem:
function gotoStackOverflow(event)
{
widget.openURL("http://stackoverflow.com/");
}
cheers... :)
Miraaj

Categories

Resources