Re: [PhoneGap] Calling phone numbers with the tel: URI scheme from JS doesn't work

443 views
Skip to first unread message

Shazron

unread,
Aug 6, 2012, 6:14:19 PM8/6/12
to phon...@googlegroups.com
Workaround: Load it through an anchor tag (create it dynamically, and
programmatically click it).

This is because when we encounter a "tel:" uri we pass it off to the
underlying UIWebView handler, and it should pop up the call dialog.
When an anchor tag is used, it is of navigation type
"UIWebViewNavigationTypeLinkClicked" which is handled properly -- but
when it is called from "window.location", it is
"UIWebViewNavigationTypeOther".

If we took out our delegate handler, and relied on the default
UIWebView handler (none of our processing), it will exhibit the same
behaviour that you are seeing. Thus, it is not a Cordova issue.

On Mon, Aug 6, 2012 at 8:06 AM, Abraham Lopez <ablop...@gmail.com> wrote:
> Calling phones from Javascript (using window.location) and the tel: URI scheme doesn't seem to be working on iPhone devices with apps packaged by PhoneGap Build, so the issue must be in the PhoneGap framework.
>
> They work alright when the app is loaded as a web app through Safari, but when it runs as a native app (where the phonegap.js file is loaded), they don't work anymore, no errors or alerts are displayed, it just doesn't do anything.
>
> Here's the code I use:
>
> function CallPhone(sPhoneNumber){
> sPhoneNumber = sPhoneNumber.replace(/[^0-9]/g, "");
> window.location = "tel:" + sPhoneNumber;
> };
>
> To try it out, just call the function when a button or link is clicked. I'm using Sencha Touch v2 to develop the app. You can also try changing the URI scheme to be "tel://" instead of just "tel:" but it will not work also. I'd like to reiterate that this code works perfectly when opening the app through Safari from a URL I uploaded the app to, but not when running it as a packaged PhoneGap app (using PhoneGap Build).
>
> --
> -- You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>
> To compile in the cloud, check out build.phonegap.com
>
>

Abraham Lopez

unread,
Aug 15, 2012, 3:01:26 PM8/15/12
to phon...@googlegroups.com
I already did this with the following code but it is NOT working at all, as it's not calling the number either.

var link document.createElement("a");
link.href ="tel:" sPhoneNumber;
link.style.visibility "hidden";
link.style.position "absolute";
document.body.appendChild(link);
link.click();

What can I do to make it work?

Abraham Lopez

unread,
Sep 20, 2012, 6:27:51 PM9/20/12
to phon...@googlegroups.com
Bumping up the thread. Can anybody help with this PhoneGap bug? Thanks!

MH

unread,
Oct 25, 2012, 11:02:51 AM10/25/12
to phon...@googlegroups.com
I finally got this to work.  I upgraded to Cordova 2.1.0 and started a brand new project from scratch.  The tel:  option now works. YAY!

Mahamat Hamid

unread,
Aug 9, 2013, 7:47:32 PM8/9/13
to phon...@googlegroups.com, mzh...@gmail.com
Hi Mr. MH

can you please show us how did you solve this issue , i am trying to make an automatic phone call but i am not able to do so

please help
Reply all
Reply to author
Forward
0 new messages