7

Can this device make a phone call?

 1 year ago
source link: https://shkspr.mobi/blog/2023/06/can-this-device-make-a-phone-call/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Can this device make a phone call? – Terence Eden’s Blog

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:

<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!



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK