Languages

Menu
Sites
Language
javascript using tizen api's to receive an SMS.

I m developing an app in which I want to use tizen api for listening for an incoming SMS, uses the message information and save it in a db.

Edited by: Nikhil Rathore on 24 Mar, 2015

Responses

5 Replies
AVSukhov

Hello,

For this purpose best way use hybrid app: web UI part + native service with listeners incoming SMS

Nikhil Rathore

Thanks for reply, well I m using web UI part only but not sure about how tizen api's can be imported in javascript.

AVSukhov

Hello,

About Hybrid app:

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.web.appprogramming/html/app_dev_process/multiple_project_dev_package.htm

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.web.appprogramming/html/basics_tizen_programming/hybrid_application_package.htm

For communication you can use Message Port:

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.web.appprogramming/html/guide/io_guide/messageport.htm

Seoghyun Kang

Dear Nikhil Rathore,

 

I'd like to recommend the Chatter sample in the Tizen SDK.

Chatter sample demonstrates how you can send and receive the SMS between devices using the Messaging Tizen API.

 

Please refer the following code about the retrieving Messages.

// app.model.js
messagesChangeListener: function Model_initSmsService() 
{
    var self = this,
 messageChangeCallback = 
 {
  messagesupdated: function onMessagesUpdated(messages) 
  {
   if (messages[0].messageStatus !== 'SENDING') 
   {
    app.ui.changeMessageStatus(messages[0]);
   }
  },
  messagesadded: function onMessagesAdded() 
  {
   self.prepareMessages(app.ui.showMessageChat);
  },
  messagesremoved: function onMessagesRemoved() 
  {
   self.prepareMessages(app.ui.showMessageChat);
  }
 };
 this.smsService.messageStorage.addMessagesChangeListener(messageChangeCallback);
},

prepareMessages: function Model_prepareMessages(callback) 
{
 var self = this;
 try 
 {
  this.smsService.messageStorage.findMessages(new tizen.AttributeFilter('type', 'EXACTLY', 'messaging.sms'),
  function onMessagesLoaded(messages) 
  {
   function compare(a, b) 
   {
    if (a.timestamp > b.timestamp) 
    {
     return -1;
    }
    if (a.timestamp < b.timestamp) 
    {
     return 1;
    }
    return 0;
   }
   messages.sort(compare);
   self.messagesList = self.groupMessages(messages);
   app.ui.loadCallerList();
   callback();
  },
  function onError() 
  {
   console.error('prepareMessage: error');
  });
 } 
 catch (err) 
 {
  console.error(err);
 }
},

 

But if you want to create the service type application, you shoud use the native or hybrid application.

 

 

AVSukhov

Hello,

Yes if you need only send and receive sms when your app is launched you can use Messaging API.

But if you want receive notification about new sms on your app when your app is closed, you need use native api with service which will be launched in background and receive notifications.