In a previous article, I outlined how the native iOS Keyboard and it’s behaviors can be managed with HTML5 input types. In addition to this, iOS, Android and most A-Grade Mobile platforms implement standard URI Schemes (or parts thereof), which allow for easily launching native applications.
When considering URI Schemes, more commonly (though incorrectly) referred to as protocols, one typically thinks in terms of the more ubiquitous schemes: http, ftp, file, mailto, about, data:uri and so forth. However, as with these and other common URI Schemes, there are additional schemes which allow for various practical applications in the context of Mobile Web Apps; the most common of which being the ability to invoke a platform’s native phone or messaging application, respectively.
URI Schemes and Mobile Devices
In the context of Mobile Web Applications, the
sms URI Schemes are perhaps the most common and applicable; providing a simple means of invoking their corresponding native applications. The following are basic examples which work across all major mobile platforms.
tel URI Scheme
The tel URI Scheme allows for launching a device’s native Phone application in the context of the phone number specified:
<a href="tel:1-800-555-1234">Call 1-800-555-1234</a>
sms URI Scheme
The sms URI Scheme allows for launching a device’s native Messaging application to send an
sms message, or to send an
sms message to the phone number specified:
<!-- launch native messaging application -->
<a href="sms:">Send a Text</a>
<!-- launch native messaging application w/phone number-->
<a href="sms:1-800-555-1234">Text Us</a>
As can be seen in the above examples, hyphens are used in the same manner as one would typically specify a phone number; however, use of visual separators are purely optional – they can be used to aid in readability if desired, but are otherwise ignored when parsing the URI.
As a general best practice, one should take care to ensure both
sms URI Schemes are defined in lowercase, so as to ensure portability across platforms. Additionally, it is important to note that the
sms scheme is not implemented to completion against it’s formal definition on any platform (see section 2.2 of rfc5724); thus, an
sms message body, or sending an
sms message to multiple recipients is not supported.
While there is nothing particularly ground breaking about these URI Schemes, or technically complex for that matter, they do prove to be quite useful in the context of Mobile Web Applications. As such, they are certainly worth noting as each can be leveraged to improve the usability of an application.