Sending SMS from a bada web application

Gabor Paller's picture

We have seen so far, how features like persistent storage or location can be accessed using elements of HTML5 in bada web applications. Bada offers deeper integration with the platform, however. The web application model supports the Wholesale Applications Community (WAC) standards and WAC APIs provide access to a wide range of device functionality including contact, calendar and task access, camera, accelerometer, local file system, device status monitoring, orientation features and messaging. In this post, we will see SMS messaging.

The example project is attached at the end of the post.

The Messaging API from WAC supports message sending, listening for incoming messages and fetching messages from the message store for SMS, MMS and e-mail. This time we will play with SMS sending. Our simple application is a variation of the "my friend's location" theme. The idea is that I want to send my location to a friend and the friend will visualize it. This time we will see the sender part.

The application starts with a familiar part: obtaining the location is the same as in an earlier example. Also, read that post how to generate location events in the emulator using the event injector. Once you injected the location event, the application prompts for the message destination address. This could be nicer, e.g. integration with the contact database could have been provided but I wanted to keep the example simple so we just prompt for a phone number. Once the phone number was obtained, we can then go ahead and send our location using an SMS message with a particular format.

The instruction to send the SMS is very simple.

First we create the message using a factory method:

            var msg =

Then we add body and target:

        msg.body = "body text"; = [ "+112345678", "+1987654321" ];

The field always has to be assigned an array of addresses, even if there is only one target, hence the square brackets.

Finally the message is sent:

                    function() {
// Success callback
                    function(error) {
// Failure callback

When this call is executed on the real device, the SM is sent to the SMS Center which sends a status response. On the emulator this functionality of the SMSC has to be simulated manually. After having sent the message, the display looks like this:























Open the event injector (by right-clicking on the emulator screen), go to the tab as seen in the picture below and click "Send sent status". There you can play with success and failure scenarios too.


Attached file: 
Taxonomy upgrade extras: