Now a lot of mobile applications are written using HTML and Javascript. It is understandable - such applications are easier to write, easier to transfer from one mobile platform to another, no need to learn Java, Objective C and other languages. However, most mobile operating systems still require some kind of wrapper. In the simplest case, you need to write a small application that will be a window of the built-in web browser maximized to the maximum. To support special features (for example, working with contacts or files), you will need to either add it to support the necessary functions, or use one of the
frameworks for writing mobile applications . In any case, you will need special tools, be it a compiler or the same framework.
However, in Symbian, starting with Symbian S60 3rd Edition, there was one good thing - Symbian Web Runtime (WRT). It allows you to develop your mobile applications using HTML and Javascript, using only standard tools of almost any desktop operating system - a text editor and a ZIP-archiver. In fact, this is also a mobile framework, but already embedded in the system, which does not require additional tools or compilation. Let's take a closer look at it?
Hello, world!
The future WRT-application (or more correctly, the WRT-widget), when first viewed, is a ZIP archive with the .WGZ extension. It contains a folder with files (if you just archive files, it will not work, only in the folder). Inside, there must be an info.plist file and a main HTML file. There may also be an icon.png file with a recommended size of 88x88 pixels, which will serve as an icon for our widget. Everything else is up to you.
The file format info.plist is almost exactly the same as that of Apple, and is described
here . Here is an example:
')
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Nokia//DTD PLIST 1.0//EN" "http://www.nokia.com/NOKIA_COM_1/DTDs/plist-1.0.dtd"> <plist version="1.0"> <dict> <key>DisplayName</key> <string>HelloWorld</string> <key>Identifier</key> <string>com.HelloWorld</string> <key>Version</key> <string>1.0</string> <key>MainHTML</key> <string>index.html</string> <key>MiniViewEnabled</key> <false/> <key>AllowNetworkAccess</key> <false/> </dict> </plist>
Parameter | Type of | Using | Description |
DisplayName | Line | Required | The name of your widget. It will be displayed in the main menu of the phone. |
Identifier | Line | Required | The unique id of the widget. |
MainHTML | Line | Required | Relative path to the main HTML file. |
Version | Line | Optional | The version of the widget. |
AllowNetworkAccess | Boolean | Optional | Give the widget network access. By default, false - access to local data only. |
MiniViewEnabled | Boolean | Optional | Give the ability to add a widget to your desktop. The default is false. If the device does not support desktop widgets, this parameter is ignored. |
If we now create an index.html file in the same folder, write something like this in it:
<html> <body> <h1>Hello, world!</h1> </body> </html>
And then compress this folder into a ZIP-archive and change its permission to .WGZ, then we will get an application for Symbian.
Here to begin with and all. You can lay out pages, write Javascript code for them, test them in your browser, and then easily and simply turn them into mobile applications for Symbian. However, it should be noted that to connect CSS and Javascript files from the Internet, you will need to enable the AllowNetworkAccess parameter.
Localization
If you want to translate your widget into many languages, you can use the built-in localization tools. It is quite simple.
To support any language, you need to create a subfolder called <language> .lproj inside the main folder (for example, "en.lproj" or "fi.lproj"):

If you want to translate the name of your widget, you need to create an infoplist.strings file and put a line like this in it:
DisplayName = " "
The rest of the localization process is quite simple. When downloading files with cascading style sheets, scripts, pictures or other resources, WRT searches for them first in a sub-folder with localization, and only then in the main folder. For example:
[main folder] \ fi.lproj \ flag.png

[main folder] \ en.lproj \ flag.png

[main folder] \ flag.png

Javascript
var flag = document.createElement('img'); flag.setAttribute('src', 'flag.png');
As a result, for the Finnish language will display the Finnish flag, for the English - English, and for all others - the purple one.
Web Runtime API
We should also mention the WRT API. It allows interaction with Symbian. WRT 1.0 doesn’t have many functions, but starting from WRT 1.1 it is possible to work with many services of this mobile operating system. About working with services - just below. Full documentation can be found on the
Symbian Web Runtime API reference page of official documentation. Below I will briefly translate some of this documentation. Some points in the documentation are simply not described or controversial, so if you notice a mistake, please write about it and I will correct it.
There are several special WRT objects that can be accessed from Javascript:
- widget - the basic features of WRT;
- menu - work with the application menu;
- MenuItem - class for creating a menu item;
- device - work with Symbian services; appeared in WRT 1.1.
In addition, a
screen object is supported, which allows you to get the device screen parameters.
Let's take a look at them one by one.
widget
Available as window.widget or simply widget. In this case, the word widget is reserved in WRT and should not be used as the name of a variable or function.
The list of methods for the widget object:
- openURL (String url ) - opens the url address in the embedded browser. At the same time, the widget does not close, but remains to work in the background. The url address must comply with RFC 1738 and all non-ASCII characters (for example, Russian letters) must be pre-encoded.
- setDisplayLandscape () - change the orientation to landscape, if supported by the device.
- setDisplayPortrait () - change the orientation to portrait, if supported by the device.
- setPreferenceForKey (String preference , String key ) - saving a key-value pair in the built-in storage. key - key, preference - value. To remove a pair from the repository, pass as a null value
- preferenceForKey (String key ) - getting the value of a key-value pair from the built-in storage. key - key. If the pair is missing, returns undefined.
- prepareForTransition (String transitionMode ) - preparation for animation. The transitionMode is a kind of animation, so far it only supports "fade".
- performTransition () - perform the animation.
- setNavigationEnabled (Boolean navigationMode ) - sets the navigation mode between items. If the navigationMode is set to true, navigation is performed using the cursor. If false, by moving between elements. By default, true - using the cursor.
- setNavigationEnabled (String navigationMode ) - set the navigation mode between items. If the navigationMode is set to "none", navigation is done using the cursor. If the "tabbed" - by moving between elements. The default is "none" - using the cursor.
- openApplication (HexNumber Uid , String param ) - open an application with Uid code and param parameters. List of application codes:
- 0x10008D39 - web browser
- 0x100058C5 - messages
- 0x101f4cce - contacts
- 0x101f4cd5 - log (list of recent calls and SMS)
- 0x100058F8 - profiles
- 0x10005901 - calendar
- 0x10005903 - watch
- 0x100058CA - sound recording
- 0x101F4668 - unit converter
- 0x10005902 - calculator
- 0x1000599d - notes
- 0x101f84eb - file manager
- 0x101f8599 gallery
- 0x101f857a - camera (on device with one camera)
- 0x101ffa86 - camera (on a device with two cameras)
- 0x102072c3 - player
- 0x10005a3e - RealPlayer
- 0x10005951 - Bluetooth
- 0x1000594d - infrared
- 0x100058ec - settings
- 0x10005a32 - themes
I will explain what the essence of the prepareForTransition and performTransition functions are. Suppose you want to hide or show some element. To do this, you use elem.style.display = "block" or elem.style.display = "none". However, if you want to animate this show or hide, you have to call widget.prepareForTransition ("fade") before it, and widget.performTransition () after it.
Here is an example from the documentation:
HTML
<div id='main'> , ! <input type="button" value="Config" onclick="toMain(0);" /> </div> <div id='config'> , ! <input type="button" value="Main" onclick="toMain(1);" /> </div>
Javascript
function toMain(main) { // widget.prepareForTransition("fade"); if (main) { // // document.getElementById("config").style.display = 'none'; // document.getElementById("main").style.display = 'block'; } else { // // document.getElementById("main").style.display = 'none'; // document.getElementById("config").style.display = 'block'; } // widget.performTransition(); }
Property list of the widget object:
- identifier - the widget's id, declared in the info.plist file.
- onshow - widget display event handler. Called when the widget transitions from the background to the active state.
- onhide - the event handler for hiding the widget. Called when the widget is in the background state.
- onexit - handler for closing the widget. Called when the widget is closed.
- isrotationsupported - if the device supports switching between portrait and landscape modes, this property is set to true. If the device supports only one mode, then false. You must check the value of this property before calling widget.setDisplayLandscape () and widget.setDisplayPortrait ().
Sub-objects of the widget object:
- wrt - contains information about the device and the WRT version:
- version is the version of the WRT. On devices using Browser / WRT 7.0, will contain "1.1". On devices with Browser / WRT 7.1 will contain a browser version (for example, "BrowserNG / 7.1.13841").
- platform.id is the OS code (for example, "S60").
- platform.romVersion - firmware version (for example, "v 31.0.008 24-8-2009 RM-365 © NMP").
- platform.manufacturer - manufacturer's name (for example, "Nokia").
- platform.packageVersion - browser / WRT version. On devices with browser / WRT will be "7.00 (0)", with browser / WRT 7.1 - "7.01 (0)".
- platform.model - device model (for example, "N97").
menu
Available as window.menu or simply menu. In this case, the word menu is reserved in the WRT and should not be used as the name of a variable or function.
With this object you can manage the application menu. The menu is assigned to the left soft button and cannot be reassigned to any other (for example, to the right). The left button is called "Options" (or otherwise in different localizations). The right soft button is called "Exit" and terminates the application. By default, the soft buttons are hidden and shown only when the user presses one of them (on the device keyboard).
The list of menu object methods:
- append (MenuItem menuItem ) - adds a menu item to the menu.
- remove (MenuItem menuItem ) - remove menu item from menu.
- getMenuItemById (Integer id ) - getting the MenuItem object with the id code. If not present, returns undefined.
- getMenuItemByName (String menuItemLabel ) - getting a MenuItem object called menuItemLabel . If not present, returns undefined. What will happen if the two points have the same name, is not described in the documentation, but most likely will return the first one found.
- setLeftSoftkeyLabel (String label , Function callbackfunc ) - sets the name of the left soft button. If title is an empty string, then the default value will be set ("Options" or other depending on localization). callbackfunc is a function that is called when a button is pressed (by default, the menu is shown). If null is passed to the callbackfunc , the button returns the default function.
- setRightSoftkeyLabel (String label , Function callbackfunc ) - sets the name of the right soft button. If title is an empty string, then the default value will be set ("Exit" or other depending on localization). callbackfunc is a function called when a button is pressed (by default, the application is terminated). If null is passed to the callbackfunc , the button returns the default function.
- showSoftkeys () - show soft buttons.
- hideSoftkeys () - hide soft buttons.
- clear () - clear the menu.
The list of menu object properties:
- onShow is a menu event handler. Called when the menu is displayed.
MenuItem
Menu item.
The list of methods on the MenuItem object:
- new MenuItem (String label , Integer id ) - constructor. Creates a new item with a MenuItem instance with the label name and id code.
- append (MenuItem childMenuItem ) - adding the childMenuItem item to the submenu .
- remove (MenuItem childMenuItem ) - removal of the childMenuItem item from the submenu.
- setDimmed (Boolean flag ) - sets whether to show the menu item or not. If false, the menu item is not displayed. If true, the menu item will be shown. By default, true - show.
The list of properties of the MenuItem object:
- onSelect - the event handler of the menu item selection. Called when a menu item is selected. Integer id - the code of the selected menu item can also be passed to the handler function.
Example from documentation:
// function menuEventHandler(id) { switch (id) { case 2001: break; case 2002: // - break; } } // function createMenu() { // var optionsMenu = window.menu; // - optionsMenu.onShow = function() { // alert('Event Trigger: optionsMenu.onShow'); } // var m1 = new MenuItem('', 2001); var m2 = new MenuItem('', 2002); // - m1.onSelect = menuEventHandler; m2.onSelect = menuEventHandler; // optionsMenu.append(m1); optionsMenu.append(m2); // var m11 = new MenuItem('', 3001); var m12 = new MenuItem('', 3002); // "" // id optionsMenu.getMenuItemById(2001).append(m11); // optionsMenu.getMenuItemByName('').append(m12); // - m11.onSelect = menuEventHandler; m12.onSelect = menuEventHandler; }
device
Available as window.device or just device. In this case, the word device is reserved in WRT and should not be used as the name of a variable or function.
This object is present starting with WRT 1.1 and opens up great opportunities to work with Symbian services with just one function.
The list of device object methods:
- getServiceObject (String provider , String interface ) - getting the service object from the provider provider and with the interface interface .
Service | Provider | Interface |
AppManager (application service) | Service.AppManager | IAppManager |
Calendar (calendar service) | Service.Calendar | IDataSource |
Contact (contact service) | Service.Contact | IDataSource |
Landmarks (service waypoints) | Service.Landmarks | IDataSource |
Location (geolocation service) | Service.Location | Ilocation |
Logging (log service) | Service.Logging | IDataSource |
Media Management (media management service) | Service.MediaManagement | IDataSource |
Messaging ( messaging service) | Service.Messaging | IMessaging |
Sensors (sensor service) | Service.Sensor | ISensor |
System Information (system information service) | Service.SysInfo | ISysInfo |
If the service is not available on the device, the method will return undefined and raise an exception. At the first attempt to access the service, the user will be presented with a dialog box asking about granting rights to use the service (“Does the application want to gain access to… Allow?”).
- getServicePermissions (Array serviceArray ) - a request from the user for permission to work with services. The list of services and interfaces is sorted in the format of {"provider": "interface", "provider": "interface", ...}. Used to get permission to use services from the user in a single dialog box. Use optional but desirable. Does not return values, but causes exceptions on error.
By itself, the section on using Symbian services in the WRT is quite large, and I will not give it here. If you find it interesting, I can describe it in a separate article. In general, the documentation is more or less clear and for each service there is a detailed example of all the functions. By the way, most functions have synchronous and asynchronous options, so your application will not slow down.
Advantages and disadvantages
Pros:
- ease of development;
- the possibility of developing without a device at hand (in the emulator or a web browser);
- the ability to use a variety of Symbian services;
- availability of documentation and examples;
Minuses:
- Unfortunately, most devices use a rather old version of WebKit, which does not support HTML 5 and CSS 3;
- Also, on the part of the devices, WRT 1.0 is still used, the functionality of which is extremely low;
- the documentation is confusing and contradictory in some places, there is no Russian translation.
The pros and cons roughly outweigh each other, and the pros are still slightly larger.
By the way, on the same Nokia N9 and Nokia N950, based on MeeGo OS with Nokia Browser 8.5 browser, HTML 5
is fully supported - you can, for example, write a game using Canvas, with support for gestures and an accelerometer. True, there is not already used WRT, and the possibility of HTML 5.
Thanks for reading. I apologize for any errors and I will be glad to give helpful comments.