Can this device make a phone call?


I want to detect if a web browser is running on a device which is capable of placing a telephone call. Is that possible?

I'm going to go with a cautious "no - not quite". Although there are several proxies which get you part of the way there.

Here's a link to a telephone number "call me!" - the HTML is:

HTML HTML<a href="tel:+441234815259">call me!</a>

You can use tel: in just the same way you'd use http: or mailto:. It tells the User Agent to open the correct program to deal with a task - either a web-browser, email client, or - in this case - the telephone dialler.

But what happens if the user is on a desktop browser? Or using a tablet computer? Or on their smart TV? Usually an error message about how the device doesn't understand the link.

So, is there a way to use feature detection to only show a tel: to devices which can handle it?

User Agent Sniffing

This practice has been discredited for over a decade. UA Strings tend to lie. And, even when they don't lie, they're not very precise.

You could use this to discover if someone is running Android - but that doesn't tell you if it's a phone, tablet, TV, or VR headset.

NetworkInformation type

The navigator object contains network information. That should tell you if the device is on a 2G/3G/4G/5G connection.

Of course, your tablet also uses those connections. And your phone might be on WiFi.

Other properties

It is possible to detect if a device is multi-touch, has a battery, is a mobile device, can vibrate, etc.

All of which, taken together, might indicate that the device is a phone. But it is far from certain.

A Big Database Of Products

Companies like 51Degrees will sell you access to their database - which includes reporting whether a specific device supports phone calls. As will DeviceAtlas.

There used to be an Open Source database called WURFL - but ScientiaMobile closed down open access to it.

To be fair, 51Degrees have a generous free tier - but it is a little depressing that this sort of feature detection is locked in a proprietary product.

If you have any ideas how to solve this please give me a call!


Share this post on…

  • Mastodon
  • Facebook
  • LinkedIn
  • BlueSky
  • Threads
  • Reddit
  • HackerNews
  • Lobsters
  • WhatsApp
  • Telegram

13 thoughts on “Can this device make a phone call?”

  1. says:

    Slightly disconcertingly, because I didn’t realise the app knew how, clicking on that on my work MacBook prompted me to open in FaceTime, which then asked me if I wanted to make the call.

    Impressed that it sensibly asked me for confirmation (once from Chrome, once from FaceTime), but I didn’t realise I could make calls from my laptop 🤯

    Reply
  2. Even if the device is capable of receiving a call, that doesn’t necessarily mean the person using the device wants a call or can hear one when it arrives - they may be Deaf or in a noisy environment.

    Why not just send them a message to ask them - is it ok to call? - if so, is it ok to call on this device?

    Or is there some other reason why you want to know?

    Reply
    1. @edent says:

      I'm sorry that I wasn't clear enough. This is to allow the user to place a telephone call. It doesn't allow the web page to call the user.

      Reply
  3. says:

    Just like Macs can forward phone call attempts to iPhones, Google Chrome (desktop browser) can do the same to Android phones. And I'm pretty sure there are a multitude of other ways (e.g. SIP software, Skype, using KDE to forward to the phone).

    Thus, while reading your post, I kept asking myself: Why do you want/need to detect that? Should you even try? Should you be able to get this answer? And does this answer even matter, given the multitude of environments and user use-cases?

    Reply
  4. said on friends.ravergram.club:

    @Edent
    I explored this as well for my contacts page. I ultimately opted for WEBRTC which will work for most any browser. Both Webcall https://f-droid.org/en/packages/timur.webcall.callee/ and Nextcloud Talk are free options for providing a link that will call my phone with no additional SW needed on caller's end. WEBRTC is also more secure and private, but it may lack the features of caller ID and voicemail. WebCall | F-Droid - Free and Open Source Android App Repository

    Reply | Reply to original comment on friends.ravergram.club
  5. said on mastodon.scot:

    @simevidas @Edent My thinking was of a similar line, but with the addition of using the Page Visibility API (https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API) as an added heuristic.

    If the page is no longer visible after clicking the link then there's a reasonable bet it's gone to a phone app. If it's still visible you've either got something that doesn't handle tel: or has multi-windows. Page Visibility API - Web APIs | MDN

    Reply | Reply to original comment on mastodon.scot
  6. says:

    Once you have detected that a device is capable of making a call, how will you detect that its user has sufficient remaining credit?

    Reply

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">