Search code examples
htmliosphone-numberphone-call

iPhone: invoking the phone from Javascript


Anyone know of any frameworks that I can use to invoke a phone call on clicking a link in Javascript?

[[UIPaaplication sharedApplication] openURL:[NSURL URLWithString:@"tel:123456"]];

I was hoping to do a web app instead of a native app.

It's easy to do in Android via addJavascriptInterface, but I was wondering if there was anything similar for iPhone?


Solution

  • Just use a regular link pointing to a tel: URL, like this:

    <a href='tel:18002752273'>Blah</a>
    

    If the user touches that link, they'll be prompted to call the number specified.

    On the other hand, if you're trying to automatically dial a number via Javascript—bypassing the confirmation alert—I'm pretty sure you're out of luck. Too much potential for exploits and annoyance.