Nokia Simplifies JavaScript for Widgets

Published by at

Forum Nokia has released a beta of Nokia Platform Services 2.0, which provides a much simplified JavaScript API with which WRT widgets can use the features of Nokia S60 devices. In addition, support for use of a device’s camera has also been introduced.

The current S60 Platform Services API, introduced with S60 5th Edition, greatly extends the capabilities developers can add to WRT widgets. The API (part of WRT API 1.1) enables widgets to access device data and information, such as contact records and location information. However, the API is constructed in a slightly obtuse manner and may be somewhat alien to most JavaScript developers.

For example, to add a contact to the device’s contacts database, using WRT API 1.1, first requires a service object for contacts to be created. The contact data to be added is then included in a criteria object whose type is set to ‘contact’. The criteria object is then added to the service object roughly as follows:

  so = device.getServiceObject("Service.Contact", "IDataSource");
  var criteria = new Object();
  criteria.Type = "Contact";
  criteria.Data = contactdata;
  result = so.IDataSource.Add(criteria);

Using the API provided by Nokia Platform Services 2.0 the code is now more straightforward:

  var contact ="", "", "");
  newcontact = { name:{ last:'smith', first: 'john'}};

Similar changes have been made across the entire range of Platform Services APIs. As a result JavaScript developers should find the task of adding platform services features to WRT widgets more straightforward.

The same simplified philosophy also applies to the new API that enables WRT widgets to call a device’s camera and receive information on the photo taken. This opens up opportunities to, for example, offer image capture and uploading to a photo sharing service from within widgets.

The new camera widget run on RDA
The light must have been out at the RDA centre when trying out the camera widget.

Each of the new APIs is supported by an example widget supplied in the download. Most of these examples embed the new JavaScript modules in their code, meaning they can be installed and run on a device immediately.

The package also includes a SIS file that installs the JavaScript library into C:\system\widgetlibs thus enabling individual widgets to be delivered without the package included in them. This SIS file installs onto S60 5th Edition devices from Nokia only.

The new APIs show a mixed response when run on the Samsung GT-i8910 HD. The camera widget started the Samsung’s camera but failed to identify the photo taken or display other media on the phone. Most of the remaining example widgets seemed to work well, although some of the functions relying on notifiers (such as updates to the system information) did not seem to work.

Nokia Platform Services 2.0 example widgets
The location and landmarks example widgets running on a Samsung GT-1810 HD

(The sensor example did not work on the Samsung either, however neither does the S60 WRT widget example for sensor support from the S60 5th Edition SDK, suggesting this feature may not be supported by Samsung at present.)

One additional feature of the new API, which does not seem to work fully, is the ability to call native editors for the addition of contacts, calendar, and landmark entries. (Currently rather than opening the editor, the relevant application is opened instead.) This mechanism has been added to provide users with the familiar data entry mechanism and overcome any reluctance to enter new records using a data entry screen built into the widget.

These issues reflect the fact that Nokia Platform Services 2.0 is currently a beta release and not designed for commercial use.

One final point, Nokia is positioning this new API as a “cross-platform” solution. While currently available for Nokia S60 devices only, the implication is that it will not be too long before WRT widgets are also available on Series 40 devices and, although it uses Mozilla, a widget environment for maemo. (Although it would make some sense for Nokia to move maemo to a common WebKit implementation.) The result would allow developers to create a single widget capable of accessing device features across the entire range of Nokia platforms.

Nokia Platform Services 2.0 can be downloaded from here. Forum Nokia also invites developers to provide feedback – which might influence the final release – on the Nokia Platform Services 2.0 discussion thread.