O'Reilly logo

Programming the Mobile Web, 2nd Edition by Maximiliano Firtman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15. Device Interaction

Mobile browsers have a large and impair ability to interact to the device, both the operating system and the hardware. The way to communicate can be driven as URIs to be used in links or as JavaScript APIs. Some specific platform supports both an API and a URI scheme for the same feature and in that case the API usually is the preferred way as being more flexible and error-free.

Apache Cordova (PhoneGap), as well as some native web platforms, adds support for more APIs than the ones available in the standard web view on every platform as we are going to see later.

Mobile-specific URIs

There are some URI schemes that many mobile browsers understand to communicate with some phone features. We can use this URIs on typical <a> elements and on some browsers, we can use JavaScript and to force the URI using location.href.

Usually, we are talking about using a protocol name, a colon and parameters, such as tel:2222.

<a href="protocol:parameters"></a>

<script>
   location.href = "protocol:parameters";
</script>

Note

The Wireless Telephony Application Interface (WTAI), part of the WAP 1.X standard was created in the last millennium and the WTAI libraries were preinstalled on the phones and can be accessed by other applications, such as the browser. To use these libraries (if available), used to use the syntax wtai://<library name>/<function name>[(;parameter)*]. Today, only feature phones still support this library.

Making a call

Remember: most mobile devices are also ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required