RSS Feed

Tizen SDK 1.0 – Porting the SMS App

Posted on

Last week Samsung released the newest version of the Tizen’s SDK and it’s called Larkspur. A lot of things have been added and you will see that the look and feel of the phone is different. If you’re interested in the release notes, you can check it here: .

I upgraded my SDK to the new one and I realized that my SMS App wasn’t working anymore and I discovered that they made some changes in the messaging API after a quick  investigation. I couldn’t find a place where they say what was changed in the API for the 1.0 version, so if you made an APP download the newest SDK and test it !

Now that we are aware of this little inconvenience I will explain that changes that must be made to the SMS app to work in this new version.

Let’s start modifying the config.xml. Now we must explicit say that we are using the Tizen API, so lets add the Tizen feature.

  • Javascript

We just need to do a little adjustment to our code. To be more specific what is affecting the App is a change in the messaging API, because now the messageStorage is declared in the SMS service so we must access this field from the SMS to be able to query the SMSs.

First we will declare a global variable called smsService to be used in the whole App:

var messagesGlobal;

var messageGlobalByUser;

var timeLastMsg;

var addressBook;

var smsService;

The smsService variable is at line 9, and the other variables were already declared before.

Now passing to the init function we will call getSmsServices()  to retrieve the SMS service and after that we load the messages in our screen. Below the init function:

var init = function () {

   console.log("init() called");




Now the getSmsService function:

function getSmsService(){




     if(services.length < 0)


       alert('No SMS service avaliable!');



     smsService = services[0];




We retrieve the serve just like before, but now we store it in a global variable to be used when send a SMS and the getMessages()  has a little change.

//Our logic starts here
function getMessages(){
       new tizen.AttributeFilter("type", "EXACTLY", "messaging.sms"),
       messageQueryCallback, onError);

Like I said the messageStorage now resides in the SMS service, so we will access from there to fetch the SMSs. The function messageQueryCallback remais unchanged.

Now in our sendSMS function instead of using a service that we receive as a parameter, we will use the global variable.

//Send the SMS to the recipients
function sendSMS(){
   var msg,content;
   var contact;
   var phoneNumber;

   content = $('#sms_to_send').val();

   contact = getContact($('#contact_number').val());

   //This means we don't have the contact in the list.
   //We only have the phone number
   if(contact != null){
     phoneNumber = contact.phoneNumbers[0].number;
   else {
     phoneNumber = $('#contact_number').val();

   if(phoneNumber == null || phoneNumber == ""){
     alert('Add a receipient');

   msg = new tizen.Message("messaging.sms", {plainBody:content,to:[phoneNumber]});

  timeLastMsg = msg.timestamp.toLocaleDateString();

  smsService.sendMessage(msg, messageSent, onError);

You can see the smsService variable being used at the last line. And that’s all the changes that we made in the Javascript.

And the HTML remains unchanged.

If you want to see the source code or clone it using git, just access this link:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: