Changes to the way you add APIs to your app

As of BlackBerry WebWorks 2.0, WebWorks apps use the same plugin architecture as Apache Cordova. A plugin provides a set of APIs, and includes the bindings between JavaScript and the native C/C++ layer of the BlackBerry 10 OS. In Apache Cordova, all communication with the native layer is encapsulated within various plugins. The BlackBerry 10 WebWorks SDK includes a number of plugins, each providing access to a different feature of the platform.

In your BlackBerry WebWorks 1.0 project, you handled access to the various APIs of the BlackBerry platform by adding <feature> tags to your config.xml file. At build time, the packager looked at the <feature> elements in the config.xml file to determine which BlackBerry WebWorks APIs to bundle with the app.

As of BlackBerry WebWorks 2.0, however, you access an API by adding the appropriate plugin to your project. When you add a plugin, the WebWorks tools add the plugin to the /plugins folder. You can determine which plugins you need to add by looking at the <feature> elements in your old config.xml file; each <feature> element maps to a corresponding BlackBerry plugin.

Plugins can be added either from the BlackBerry 10 WebWorks SDK web tool, or from the command line.
  • To use the BlackBerry 10 WebWorks SDK web tool, open BlackBerry WebWorks <version>, then click the Plugins button under your project's name in the navigation panel.
  • To use the command line, navigate to your project folder and then run:
    webworks plugin add <id> 
    where <id> specifies the unique identifier for the plugin.

A note about using HTML5 notifications

You should be aware that if you used HTML5 notifications in your previous app, you need to add a plugin to access this functionality, even though it required no <feature> element previously. To access the same functionality, add the com.blackberry.notification plugin to your app.

Mapping BlackBerry WebWorks plugins to BlackBerry features

The following table outlines how BlackBerry WebWorks plugins map to the <feature> element entries in your existing config.xml file.

If you added this <feature> element: You need to add this plugin:
<feature id="" />
<feature id="blackberry.bbm.platform" /> com.blackberry.bbm.platform
<feature id="blackberry.connection" /> com.blackberry.connection
<feature id="blackberry.identity" /> com.blackberry.identity
<feature id="" /> com.blackberry.user.identity
<feature id="blackberry.invoke" /> com.blackberry.invoke
<feature id="blackberry.invoke.card" /> com.blackberry.invoke.card
<feature id="blackberry.invoked" /> com.blackberry.invoked
<feature id="" />
<feature id="" /> The plugin has been deprecated since BlackBerry WebWorks 2.2. Modify your app to use org.apache.cordova.file-transfer instead.
<feature id="blackberry.payment" /> com.blackberry.payment
<feature id="blackberry.pim.calendar" /> com.blackberry.pim.calendar
<feature id="blackberry.pim.contacts" /> com.blackberry.pim.contacts
<feature id="blackberry.push" /> com.blackberry.push
<feature id="blackberry.sensors" /> com.blackberry.sensors
<feature id="blackberry.system" /> com.blackberry.system
<feature id="blackberry.system.event" /> No longer supported. Event listeners must now be added to and removed from the document object. For backwards compatibility, events added to the sytem.event object are mapped to the document object, so no coding changes are required.
<feature id="blackberry.ui.contextmenu" /> com.blackberry.ui.contextmenu
<feature id="blackberry.ui.cover" /> com.blackberry.ui.cover
<feature id="blackberry.ui.dialog" /> com.blackberry.ui.dialog
<feature id="blackberry.ui.toast" /> com.blackberry.ui.toast

Last modified: 2015-03-19

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus