You Are Here:

Community: Wiki

This page was last modified on 20 January 2009, at 07:42.

CS001236 - Showing messages information notifications in WRT

From Forum Nokia Wiki



ID CS001236 Creation date December 18, 2008
Platform S60 5th Edition Tested on devices Nokia 5800XpressMusic
Category Web Runtime (WRT) Subcategory Messaging


Keywords (APIs, classes, methods, functions): device.getServiceObject(), Service.IMessaging.RegisterNotification(),

Service.IMessaging.Send()

Overview

This code snippet shows how to register your application to receive notifications on sent messages using the Messaging Platform Service for S60 Web Runtime introduced in S60 5th Edition.

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

After setting up the values for the notification type (notificationCriteria.NotificationType), the IMessaging.RegisterNotification(notificationCriteria,showMessagesStatus) method is used to register for notifications. The IMessaging.RegisterNotification() method is asynchronous and uses the showMessagesStatus() as a callback function.

Source: Relevant HTML components

<p id="status"></p>

Source: JavaScript file

var serviceObj = null;
 
// Initializes the widget
function initialize() {
document.getElementById("status").style.display = "none";
 
// Obtain the service object
try {
serviceObj = device.getServiceObject("Service.Messaging",
"IMessaging");
} catch(exception) {
alert("Service object cannot be found.");
return;
}
}
 
function sendMessageAndNotify() {
// The sending part omitted. Refer to the See also section for the code
// snippet that provides you with more information about the sending.
// ...
 
try {
var notificationCriteria = new Object();
notificationCriteria.Type = "NewMessage";
//Registering for notification on new events.
var result = serviceObj.IMessaging.RegisterNotification(
notificationCriteria, showMessagesStatus);
} catch (exception) {
alert("Register message notification error: " + exception);
}
}
 
/**
* Callback function used to handle changes in the messaging status.
* @param transId This is a number representing the transaction that called
* the callback
* @param eventCode This is a number representing the callback return status.
* @param result This is an object for holding the callback return value.
*/

function showMessagesStatus(transId, eventCode, result) {
if (result.ErrorCode == 0) {
document.getElementById("status").innerHTML =
"You have a new message!";
document.getElementById("status").style.display = "block";
}
}

Postconditions

The snippet shows how to register for receiving notifications on message status changing.

Supplementary material

The source file and executable application are available for download at Media:Showing_messages_information_notifications_in_WRT.zip.

See also

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fSeriesE5f60E25E457E25ACE25ACE25E454E25B8E2589E25E457E2589E2588E25E454E25B8E258AE25E456E258FE2590E25E455E258FE2596E25E456E25B6E2588E25E456E2581E25AFE25E457E259AE2584E25E459E2599E2584E25E454E25BBE25B6X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZmessagingQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxmessagingX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ