The Messaging Service API allows widgets to send, retrieve, and manage messages using the Messaging Center of a device. You can use the Messaging Service to create widgets that:
Send SMS and MMS messages
Retrieve messages stored on the device
Notify the user when new messages arrive
Change the status of a message
Delete messages
To create a service
object for the Messaging Service API, use Service.Messaging
to
identify the service provider and IMessaging
to identify
the supported interface:
var so = device.getServiceObject("Service.Messasing", "IMessaging");
The IMessaging
interface provides the following
methods:
Use the GetList()
method to retrieve messages stored
in the Messaging Center of a device.
Use the Send()
method to send an SMS or MMS message.
Use the RegisterNotification()
method to receive
notifications of new incoming messages.
Use the CancelNotification()
method to cancel notification
of new incoming messages.
Use the ChangeStatus()
method to change the read
status of a message.
Use the Delete()
method to delete a message.
Use the Cancel()
method to cancel an ongoing asynchronous
call. This method is valid for any asynchronous call made through the Messaging
Service API.
To perform messaging tasks using the Messaging Service API:
Create a service
object for the API using device.getServiceObject()
.
Define the messaging tasks you want to perform and choose the correct methods for them.
Optionally, define how you want the results filtered.
Define methods to process the results.
Use the methods
defined in step 2 to perform the messaging tasks. Use asynchronous methods
together with callback()
.
Process the results in the methods defined in step 4.
For the complete source of a sample widget that demonstrates how to use this service, see the full example.