×
Namespaces

Variants
Actions
(Difference between revisions)

Removing message from Inbox in Symbian Web Runtime

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
hamishwillee (Talk | contribs)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
|sourcecode= [[Media:Removing message from Inbox in WRT.zip]]  
+
|sourcecode= [[Media:Removing message from Inbox in WRT.zip]]
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|devices= Nokia 5800 XpressMusic
 
|devices= Nokia 5800 XpressMusic
Line 95: Line 95:
 
==See also==
 
==See also==
  
* [[CS001246 - Listing inbox messages in WRT]]
+
* [[Listing inbox messages in Symbian Web Runtime]]
  
[[Category:Symbian Web Runtime]][[Category:Code Examples]][[Category:Messaging]][[Category:S60 5th Edition (initial release)]][[Category:Code Snippet]]
+
[[Category:Symbian Web Runtime]][[Category:Code Examples]][[Category:Messaging]][[Category:S60 5th Edition]][[Category:Code Snippet]]

Latest revision as of 07:40, 1 August 2012

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
S60 5th Edition
Article
Keywords: device.getServiceObject(), Service.Messaging.Delete()
Created: dekuykin (10 Dec 2008)
Last edited: hamishwillee (01 Aug 2012)

Contents

[edit] Overview

This code snippet shows how to delete a message from the Inbox using the Messaging Platform Service for S60 Web Runtime introduced in S60 5th Edition.

The device.getServiceObject("Service.Messaging", "IMessaging") method is used to get access to the service object for the Messaging Service API.

[edit] Source

The HTML select component contains the messages:

<select size="5" id="messageList" multiple></select><br />
var serviceObj = null;
 
// Initializes the widget
function init() {
try {
serviceObj = device.getServiceObject("Service.Messaging",
"IMessaging");
} catch (ex) {
alert("Service object cannot be found.");
return;
}
}
// Removes the message which is selected in the list box.
function removeMessage() {
// Get a reference to SELECT object which contains the list of messages
var messageList = document.getElementById("messageList");
 
var criteria = new Object();
// Find the selected messages
for (var msgIndex = 0; msgIndex < messageList.length; msgIndex++) {
if (messageList.options[msgIndex].selected) {
// Get message id of the selected message
var messageId = messageList.options[msgIndex].value;
// Radix of message id integer value
var radix = 10;
// Get numeric representation of the message id
criteria.MessageId = parseInt(messageId, radix);
// Delete the message
var result = serviceObject.IMessaging.Delete(criteria);
if (result.ErrorCode !== 0) {
alert("Error in deleting messages");
break;
}
// Remove message record from selection list
messageList.remove(msgIndex);
msgIndex = msgIndex - 1;
}
}
getMessageList();
}

[edit] Postconditions

The selected SMS or MMS messages are deleted.

[edit] Supplementary material

You can view the source file and executable application in the attached ZIP archive. The archive is available for download at Media:Removing message from Inbox in WRT.zip.

[edit] See also

This page was last modified on 1 August 2012, at 07:40.
58 page views in the last 30 days.