BlackBerry 10 Developer’s Guide to SMS

HOW-TO / 09.24.13 / mdwrim



SMS (or “Text Messaging”) has been around for ages. But these days, BlackBerry users and BlackBerry developers have a wide range of messaging systems available to them including BBM and the excellent BlackBerry Push service. So is there still a place for SMS and if so, how can you exploit it from a BlackBerry 10 application?

The answer to the first question is YES! As for the second question, there are BlackBerry 10 Cascades APIs that allow you to develop applications that exploit SMS in a variety of ways.

To help BlackBerry developers get the most out of our SMS-related APIs, I’ve written a technical knowledge base article which you’ll find in our developer resource centre (link below) and published a video presentation in our YouTube BlackBerry Developer channel. This blog post acts as an introduction to the topic, but if you want to know more, check out the article and the video!

What is SMS good for?

SMS is still *the* primary, perhaps even the *only* truly cross-platform, mobile messaging system. You can send an SMS from almost any mobile device that has a SIM card in itand know that the device that receives it will support SMS and be able to process it. The device could be the cheapest feature phone in the world and the chances are it will still support SMS. So SMS has a “works anywhere appeal.”

SMS can be used for more than just mobile-to-mobile messaging. There are numerous server based (I’m loath to say “cloud based”) services that send and receive SMS messages from mobile devices. By definition, such services tend to need to support a very wide range of mobile device types.

SMS can be used for more than just text. It’s possible and common to send binary SMS messages, which either contain standard object types such as pictures (yes you can send simple bit maps by SMS and I’m not talking about MMS here by the way) or proprietary binary objects of your own design.

Store and Forward

SMS is a “store and forward” system. When you send an SMS message from your device, you immediately hand over responsibility for its final delivery to the mobile network. Your request is asynchronous and having submitted it, you can continue doing other things and not have to wait for the message to be delivered.

In fact, your message is not delivered directly to the device it is addressed to when you send it. It is first delivered to a server known as an SMSC (Short Message Service Centre) which is operated by the mobile network operator that issued you with your SIM card. You can see the address of the SMSC in the Text Messages Advanced Settings screen of your BlackBerry 10 device. Yes, it looks rather like a phone number; in fact that’s a network address sometimes referred to as a “global title” or “GT.”


The SMSC will then determine where the device, to which the SMS is addressed, is currently located geographically and its current status. Essentially, the delivery process needs to establish the base transceiver station (that’s the cellular network mast) from which the message must be transmitted over the radio link to the destination device and other information such as whether or not the target device is currently switched on. It does this using other mobile network services that I won’t go into here.

Once the location and status of the destination device have been ascertained however, the SMSC will try to deliver the message. If it cannot deliver right away for anything other than there having been a fatal and permanent error reported, the SMSC will hang on to the message and queue it for a series of retries later on or for delivery when the destination device contacts the SMSC and says “I’m ready and available to receive SMS messages now.” For example, the first time the SMSC tries to deliver the message, it might find that the destination device is currently switched off or that it reports that it has no space available in its inbox. These would be regarded as temporary problems and delivery of the message would be retried later on.

There’s a limit to how long an SMSC will retain a message and keep retrying delivery. SMS messages have an attribute known as a “validity period.” This defines the maximum age an SMS message may attain without having been delivered before the SMSC should give up attempting to deliver it and delete it. In practice, SMSCs have their own maximum validity period and this may override any value specified for a particular message. Typically, messages will be retained and retried for several days or perhaps more.

The store and forward architecture of SMS as implemented by SMSCs make SMS ideal for “fire and forget” scenarios.

You may wish to track the outcome of submitting a message however. Was it eventually delivered or not?

Delivery Receipts

Cellular networks typically support a mechanism known as “status reports.” These are also known as “delivery receipts” and are special messages which can be returned to a message sender to indicate the eventual fate of a message that was sent some time ago. On a BlackBerry 10 device, you can switch on delivery receipts via the Text Message basic settings screen.


By switching on Confirm Delivery for SMS, you’ll see status indicators next to SMS messages you send, change to have a little icon containing a “D” to indicate that your message was delivered. Behind the scenes, your BlackBerry 10 device knows that this is the case because the mobile network delivered a delivery receipt to it.

Size Limits

SMS does of course have its limitations. The maximum length of a single SMS message is one such limitation. I often hear people state that the maximum size of an SMS message is 160 characters. In fact, the limit is 140 bytes. A text-based SMS will either contain a series of 7 bit characters or a series of 16 bit UCS2 encoded characters. 7 bit characters, often drawn from the GSM 03.38 character set, are left shifted so that every available bit is used. Consequently (do the math), you can fit 160 x 7-bit characters in your 140 byte payload; or 70 x 16 bit Unicode USC2 characters; or 140 x 8 bit binary bytes; or a mixture of both character and binary data. Yes, it can get a little complicated.

Why would you mix character and binary data in the same SMS message? Well there are many reasons, but one would be to exploit something called “concatenation”. It’s possible for multiple SMS messages to be encoded such that they are each designated as a particular, numbered segment of a larger SMS message which comprises the text part from each of the segments, all joined together. This is how it’s possible to send an SMS which contains many more than 160 characters. BlackBerry 10 takes the “long” text message that you keyed in and encodes it as a series of separate but related, concatenated SMS message segments.

APIs to the rescue

My goal in providing this basic guide to SMS is to hopefully give useful background information about SMS to developers who have not worked with the technology before. If I’ve managed to make it sound complicated, don’t worry! BlackBerry 10, the Cascades APIs and the mobile network take care of the greater majority of the issues I’ve described, completely by magic and without any effort needed from you, the developer.

So let’s talk about developing BlackBerry 10 applications that exploit SMS next.

SMS Applications Development on BlackBerry 10

In simple terms, developers will want to do one or both of two things with SMS in a BlackBerry 10 application; send SMS messages or receive them. But, there are two distinct scenarios for each of these simple use cases; either the application is working with SMS messages in much the same way that a user would via the BlackBerry 10 text messaging application, creating or receiving text messages that are intended to be “consumed” by a human recipient or, they are using SMS as a transport for binary data, to be sent or received to/from another device or server-resident messaging service and consumed by an application. I call the first of these scenarios: “user directed SMS” and the second, “port directed SMS” due to the way in which we target an application with our binary SMS data.

In addition to my knowledge base (KB) article and video presentation, I’ve also written a couple of sample applications. The first application shows how to send and receive user directed SMS messages and the second, port directed SMS. The KB article walks through the code in each of the sample applications and explains the BlackBerry 10 API use for both sending and receiving SMS in both the user directed and port directed cases. The code for both applications is available in the Cascades Community Samples GitHub repository.


You’ll find the article here:

The video presentation here:

And the sample applications in GitHub here:

Enjoyed this blog post?


About mdwrim