How do I detect availability of tel: uri scheme in a web app?
Asked Answered
K

3

17

I'm looking to use the tel: uri scheme (rfc3966) to make phone numbers linkable on mobile devices in a web application, but I'd prefer to not link them on devices that can't handle the tel: scheme - desktops, or mobile devices without phone functionality (i.e. iPads!)

Is there some way to detect this? I'd prefer to avoid user agent sniffing, if possible.

The iPhone seems to have a canOpenURL function that apps can use to test this, but I'd like to get the same behaviour from Javascript.

Kunzite answered 22/2, 2011 at 4:7 Comment(0)
I
4

There's no standard way of detecting browser support for the tel URI scheme.

You can however user-agent sniffing library, such as the excellent WURFL library which can detect this feature.

Interpleader answered 22/2, 2011 at 20:3 Comment(4)
Would you happen to know whether this situation has changed much over the past year? (I suspect not.) Thanks for the answer.Garner
Not as far as I know, would be nice to see some kind of JavaScript support to detect this. Best bet would be to just place the telephone number on the page and hope that the phone interprets it as a phone number and converts it into it's version of the tel: link.Interpleader
Yes, though the ugly part isn't only whether it does something useful on the phone, but also whether desktop browsers will do something clumsy. Desktop Firefox gives the user a nice dialog explaining that the URL scheme is not recognized, which is of course utterly wasted on normal people just looking at a page. Well again, thanks!Garner
User-Agent sniffing is not the answer, the user agent string cannot determine if a device has the capability, there is simply not enough information provided. Is Skype Installed, is this android device a tablet, or running on a pc?Offspring
B
1

The iPhone will automatically pick up whether general text is in phone number format and turn it into a clickable link. No effort required on your side.

ie If you have text "+61 (0)7 3000 0000" on your site the iPhone will know it's a number and make it a link.

Benitabenites answered 25/2, 2011 at 5:13 Comment(2)
Other mobile devs have told me that it's best to turn this feature off, as it tends to aggressively turn other stuff into clickable links as well - such as postcodes, post office boxes, and other long strings of numbers. The advice might be out of date - anyone know if this is still a problem?Kunzite
@Kunzite It's a problem/feature depending on how useful you think it is. It can be disbaled by using <meta name="format-detection" content="telephone=no">Interpleader
U
0

The MobileESP project has APIs for several server-side languages, as well as a client-side JavaScript API.

Oh! and it's free and open-source (Apache license I believe)

Unformed answered 30/7, 2015 at 8:56 Comment(1)
This is basically user-agent sniffing.Offspring

© 2022 - 2024 — McMap. All rights reserved.