Samsung Web API enables you to create applications with messaging functionalities for SMS, MMS, and email using the Messaging API.
The messaging process used in HTML5 involves Uniform Resource Identifiers (URIs), which form values of attributes, such as tel, mailto, and sms. These attributes invoke external services which then perform the messaging tasks. The Messaging API minimizes your coding efforts by providing one-step capabilities to perform all high-level messaging-related operations.
The main features of the Messaging API include:
- Message writing
You can write a message by using the Message interface constructor, and you can set the message attributes and parameters using a MessageInit object (for example, you can set the message service type - SMS, MMS or email - by using the type attribute).
You can add attachments to your MMS and email messages as an array of MessageAttachment objects by creating the attachments and defining the file path and the MIME type (image/png, text/pdf, or text/html) for them.
To save message drafts for later, use the addDraftMessage() method of the MessageStorage interface.
Note The system assigns a unique read-only message ID to each message the first time it is processed, such as when sending it or creating a draft message for it.
- Message sending
The method requires both success and error event handlers. Depending on the result of the sending operation, the message is moved to the device's Sent Items folder or Drafts folder, and additionally stored in the message storage database.
- Message management
You can find, update, and delete stored messages with methods provided by the MessageStorage interface: findMessages(), updateMessages(), and removeMessages(). The interface allows you to manage message storages.
- Message storage change notifications
You can register event listeners to monitor changes in the message storage, a particular conversation, or a particular message folder.
The addMessagesChangeListener(), addConversationsChangeListener(), and addFoldersChangeListener() methods of the MessageStorage interface register an event listener, which starts asynchronously once the method returns the subscription identifier for the listener. You can use the MessagesChangeCallback, MessageConversationsChangeCallback, and MessageFoldersChangeCallback interfaces to define listener event handlers for receiving notifications about the changes.
- Conversation management
You can load email messages and attachments from the email service with the loadMessageBody() and loadMessageAttachment() methods of the MessageService interface.
To keep your email service accounts up-to-date, synchronize them with their respective external servers, such as Gmail and Microsoft Exchange, with the sync() method. You can also synchronize just one folder, such as the Inbox, with the syncFolder() method.
You can specify the maximum number of messages that can be retrieved in each folder.