×
Namespaces

Variants
Actions

How to read SMS Inbox in WRT Widget

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Tested with
Devices(s): Nokia N97 Mini
Compatibility
Platform(s): S60 5th Edition
S60 5th Edition
Article
Keywords: IMessaging.GetList(), SMS Inbox.
Created: vasant21 (21 Jan 2010)
Last edited: hamishwillee (14 Jun 2013)

Note.pngNote: Support for S60 Platform Services through Platform Services APIs was introduced in WRT 1.1. The Platform Services 1.0 APIs were formerly known as Service APIs. Widgets created using WRT 1.1 Platform Services APIs do not work with WRT 1.0.


Overview

This article and code snippet below demonstrates how to read SMS inbox messages synchronously using the Platform Service 1.0 Messaging Api in S60 Web Runtime.

Using Platform Services 1.0

To obtain access to the service object for the Messaging Service API in Platform Services 1.0, the device.getServiceObject("Service.Messaging", "IMessaging") method is used.

Source

<html>
<head>
<script language="javascript">
function readInbox(){
 
try {
var so = device.getServiceObject("Service.Messaging", "IMessaging");
} catch(e ) {
alert("Error in getting Messaging interface \n" + e);
return;
}
 
 
// Our criteria is to get inbox SMS messages.
var criteria = {
// Specifies the type of messaging objects to retrieve.
// Possible values "Inbox", "NewMessage" etc..
Type : "Inbox",
Filter :{
//Specifies the type(s) of messages to retrieve.
// Possible values are "SMS", "MMS" & "unknown"
MessageTypeList : ["SMS"]
}
};
 
// Lets get the messages with the above prepared criteria, synchronously.
var result = so.IMessaging.GetList(criteria);
 
// Lets print the received message list in html page.
var items = result.ReturnValue;
var message = "";
var list = "";
while (( message = items.getNext()) != undefined ){
list += "<b>"+message.Sender+"</b> - "+ message.Subject + "<br/><br/>";
}
 
document.getElementById('log').innerHTML += list;
 
};
</script>
</head>
<body onLoad="readInbox()">
<div id="log">Read SMS Inbox in WRT Widget Example<br/></div>
</body>
</html>



Sample Widget

Here is a sample widget application, uses Platform Services 1.0 Messaging API.

Postconditions

  • When the application is launched, the user will see the list of inbox messages in the HTML page, if the inbox is not empty.
This page was last modified on 14 June 2013, at 09:28.
56 page views in the last 30 days.