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!
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 🤯
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?
@edent says:
Reply to original comment on crispsandwi.ch
|Reply to original comment on mastodon.social
|the phone number is displayed as plain text2. there is a “Call” button next to it3. clicking that button opens a custom dialog4. the dialog displays the tel: link (<a>) and an explanation that the link might not work
Reply to original comment on mastodon.social
|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?
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 to original comment on friends.ravergram.club
|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 to original comment on mastodon.scot
|Reply to original comment on mastodon.social
|Reply to original comment on mastodon.me.uk
|More comments on Mastodon.