Jump to content

How to Send a Text Message from Your Mobile Website

+ 3
  Maximiliano Firtman's Photo
Posted Oct 26 2010 01:17 PM

We all like the Short Message Service; that’s why mobile browsers generally offer the ability to invoke the new SMS window from a link. To do this, we have two possible URI schemes, sms:// and smsto://. Unfortunately, there is no standard way to know for sure which one is compatible with a user’s browser.

Note: Wireless Universal Resource File (known as WURFL) can be used to detect sms: and smsto: protocol compatibility from the server so you can select the right alternative.

The syntax is sms[to]://[<destination number>][?parameters]. As you can see, the destination number is optional, so you can open the SMS composer from the device without any parameters defined. The parameters usually define the body, but this property is not compatible with all phones for security reasons (e.g., to avoid a website sending premium SMS texts). As with sending an email, an SMS is not automatically sent when the user presses the link. The link only opens the SMS Composer window; the user must finish the process manually.

The destination number should either be an international number or, if it is a short number code, we should guarantee that the user is in the right country and is connected with one of the compatible carriers of that short code.

Note: BlackBerry devices offer direct messaging between two BlackBerry devices on the same network. For creating a direct message, you can use the PIN:<number> URL scheme.

Here are some samples:

<a href="sms://">Send an SMS</a>

<a href="sms://?body=Visit%20the%20best%20site%20at%20http://mobilexweb.com">
Invite a friend by SMS<a>

<a href="sms://+3490322111">Contact us by SMS</a>

<a href="sms://+3490322111?body=Interested%20in%20Product%20AA2">
More info for producto AA2</a>

Working with MSS
The Multimedia Messaging Service (MMS) is the standard way to send messages with multimedia content (images, video, or any attached content). It depends on the SMS standards and a content file (the multimedia message) that the sender uploads to the carrier and the recipient downloads from the carrier. Symbian devices allow us to define the URI schemes mms:<url> to download an MMS file from the specified URL and mmsto://<destination number> to open the Multimedia Message Composer.

The table below lists which messaging features work with which platforms.

Messaging actions compatibility table

Browser/platformsms:/smsto: schememms:/mmsto: schememailto: scheme
SafariOnly sms: and in iPhone (not iPad/iPod). No body support.NoYes
Android browserYes, no number or body supportYes, no number or body supportYes
Symbian/S60Only sms:Only mmsto:Yes
Nokia Series 40No (use mailto: instead)NoYes (it can also be used for SMS and MMS)
webOSOnly sms:NoYes
Openwave (Myriad)NoNoYes
Internet ExplorerOnly sms:NoYes
Motorola Internet BrowserNoNoYes
Opera MobileYesYesYes
Opera MiniDepends on the deviceDepends on the deviceDepends on the device

Note: If you are developing mobile widgets or offline Javascript applications, almost every platform provides a low-level API for sending messages and even receiving them from your application.

Programming the Mobile Web

Learn more about this topic from Programming the Mobile Web.

How do you take advantage of the new opportunities opening up in mobile web development? With this book, you'll learn the intricacies and pitfalls involved in building HTML and CSS-based apps that you can extend to work with particular devices, including the iPhone, Nokia, Blackberry, Android devices, and other smartphones. You'll not only learn how to deal with platform variations, finicky browsers, CSS compatibility, and other issues, but also how to create pleasant user experiences in a constrained environment.

See what you'll learn

1 Subscribe

1 Reply

  Rahul C's Photo
Posted Apr 24 2012 08:20 PM

Is there a sample of complete implementation of click-to-sms including detection of various OS/Browsers and customizing response accordingly? I've searched a lot but cannot find any suitable samples.