Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see if tel: is actually linked to a device that can make a call?

Tags:

php

tel

I'm currently on a project that needs to detect whether or not a device can make a phone call. Depending on whether or not it can, I need to switch views and apply two different functions, one is a button to make a call to a particular number using tel: on html, the other is a button for you to enter your number and we'll call you using fonality.

Currently, I've managed to install such plugins/libraries such as wurfl or terawurfl, none which seems to have a 100% reliable way to detect whether the mobile phone or tablet/desktop can make a phone call.

Is there any server side or user side solution to this like a tag that I missed in wurfl/terawurfl or even a javascript ajax call that I could make to detect "yes tel: works" or something of that nature.

like image 396
Jerry Tseng-shen Hsu Avatar asked Jul 12 '12 07:07

Jerry Tseng-shen Hsu


1 Answers

Here is a PHP class I use which detects mobile browsers that you can download fro free. http://code.google.com/p/php-mobile-detect/

Once the class in set up correctly you can use code like this:

if ($detect->isMobile()) {
    // any mobile platform
    // place telephone code here
}

or you can be more specific:

if($detect->isiOS()){
    // code to run for the Apple iOS platform.
}

This is generally used for creating mobile websites however it will fit your purpose :)

like image 112
Peter Stuart Avatar answered Sep 23 '22 15:09

Peter Stuart