Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How-to create self-updating WRT widgets

From Wiki
Jump to: navigation, search
Article Metadata
Compatibility
Platform(s): S60 3rd Edition FP2
Symbian
S60 3rd Edition FP2
Article
Created: forum-mrkt (03 Oct 2007)
Last edited: hamishwillee (12 Oct 2012)

Contents

Theory

For Symbian Web Runtime the easiest way to do self-update is to have application to do version checking by itself. A variable in the widget's bundle can indicate current version that can be checked against server interface. This approach doesn't require any extensions or platform tricks, it is pure JavaScript implementation.

Example setup

Following example assumes that you have script running on server side at http://myexample.versionservice.com:8888. Server responds to version request with XML document including version tag. This example can be easily extended e.g. to include update url in version response message.

Example code

/*
* version server url, and current version
*/

var versionURL = "http://myexample.versionservice.com:8888";
var currentVersion = 1;
 
var reqV = null;
 
/*
* called e.g. during app startup or once a day
*/

function checkForUpdate()
{
/*
* asynch XHR to server url
*/

reqV = new XMLHttpRequest();
reqV.onreadystatechange = checkVersion;
reqV.open("GET", versionURL, true);
reqV.send(null);
 
document.getElementById("updateDIV").innerHTML = "checking for updates";
}
 
/*
* parse response and check version
*/

function checkVersion()
{
if (reqV.readyState == 4)
{
if (reqV.status == 200)
{
/*
* little overhead here, one could use also string for version info
*/

var newVersion = reqV.responseText;
if (currentVersion != newVersion)
{
document.getElementById("updateDIV").innerHTML =
"<a href=\"http://www.taika.org/~jario/newversion.wgz\">
Download new version</a>"
;
}
else
{
document.getElementById("updateDIV").innerHTML =
"No new versions available";
}
}
else
{
alert( "connection error" );
}
}
}

Example main HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type='text/javascript' src="selfupdate.js"></script>
</head>
<body onload="checkForUpdate();">
 
<div id="updateDIV"></div>
 
</body>
</html>
This page was last modified on 12 October 2012, at 06:21.
116 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×