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
<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!
@edent says:
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
More comments on Mastodon.