WebWorks: If you've built a web app, you can build a BlackBerry 10 app

Credit: Blackberry

Now that the BlackBerry 10 smartphone platform has finally been launched, along with the new Z10 and Q10 devices, it’s clear that the newly re-named BlackBerry is targeting the BYOD market with the latest version of BES and its new OS. Built on the QNX real time OS, BlackBerry 10 can take advantage of its built-in sandboxing to separate personal and corporate data – and personal and corporate applications.

With a device running BlackBerry Balance, IT departments are able to lock down corporate partitions and corporate data, while your own personal apps and information can run uncontrolled. There’s separation of church and state, data can’t be shared across the partitions even though you can be running a personal app at the same time as a business app.

[See also: REVIEW: Apple And Google have nothing to fear from Blackberry 10, but Microsoft does.]

That means it’s easier to build and run your own apps. While your code might be designed to work inside the corporate Balance partition, you can build and test in your own space without affecting corporate apps. Once an app is ready to distribute you can work with IT to get it signed with a digital certificate and added to a private enterprise store. Of course if you’re working with publicly accessible data and services you can add your app to the public BlackBerry World store, or sideload it onto colleagues’ devices using a free code signing key.

Credit:Screenshot/BlackBerry
BlackBerry's revamped Developer site.

BlackBerry has taken an unusual, and interesting, approach to mobile application development -- one that’s more akin to the PC model. Instead of limiting development to one framework and one toolkit, BlackBerry 10 gives you a wide choice of different application development frameworks – from C++ and QT, to ActionScript and AIR, to HTML5 and BlackBerry’s own WebWorks – and Android apps can be wrapped and delivered as BlackBerry apps, running on a version of the Android virtual machine. All deliver code that runs on the device, and that can take advantage of core device APIs, including access to device sensors and integration with the BlackBerry Messenger Service.

More a combination of tools than a single development environment, WebWorks is the ideal onramp to BlackBerry 10 for anyone who’s built a web application. It’s based on familiar HTML and JavaScript, so you can quickly port existing web apps to BlackBerry 10 – even bringing along any JavaScript libraries you’re currently using (though you’re probably better off porting to mobile versions where available). To get started you’ll need to download the Ripple emulator, which runs as a Chrome Extension, the BlackBerry WebWorks SDK, and the BlackBerry 10 Dev Alpha Simulator (which is actually a VMware image of the BlackBerry 10 OS recompiled for x86).

If you’ve tried downloading BlackBerry development tools in the past, you’ll find the new BlackBerry developer site a lot easier to use – and there’s no need to register for downloads. All you need to do is click and go…

Credit: Screenshot/BlackBerry
Get started with WebWorks by downloading free tools

Building a WebWorks app is just like building a mobile web site – and you can use the same tools you’ve always used. Code can be edited in any development environment, whether it’s a basic text editor or a web design package like Dreamweaver. You’ll need to start with a config.xml file that describes the app you’re building. You’ll use this to describe the resources, features, and capabilities of an application – as well as the permissions it needs on a device. If you’ve developed an HTML widget for any other framework in the past you’ll find configuring a WebWorks app very familiar – right down the XML syntax of the configuration document.

Application code mixes HTML markup and JavaScript (with support for CSS and for JavaScript libraries). You don’t need to use RIM’s own webworks.js library unless you’re using BlackBerry features and services. Working with HTML application frameworks like WebWorks means you can take advantage of the page-oriented nature of web apps to separate code into blocks of presentation and business logic. An entry page can contain the code to handle logins, while a separate page can handle capturing data and delivering it to an external service, while yet another deals with formatting and displaying results.

The Ripple emulator is an important part of WebWorks, as it lets you quickly test your code inside a desktop browser, without needing to run a full device emulator. Once installed in Chrome, all you need to do to test your app is click the Ripple button in the toolbar. You will need to configure the SDK path, the root folder for a project, and a name for the final app (and where you want to deliver the compressed files that make a completed app). Once you’ve tested an app you can click the package button and run the resulting files on an emulator or on a BlackBerry 10 device.

Credit: Screenshot
Test WebWorks apps in Chrome using the Ripple emulator

If you don’t want to make an app available through BlackBerry World you can use debug tokens to sideload on to up to 100 BlackBerry devices. Tokens are valid for up to 30 days at a time, and let unsigned apps run – once a token expires you’ll need to install a new version of the app with a new token. You can only have 100 tokens in use at any one time, so it’s a procedure that’s really only suitable for departmental applications or for your own personal code.

WebWorks apps can take advantage of many of the same device features as native BlackBerry apps. These include the ability to launch other apps and to get access to the device location. The launch API lets you do a lot more than just fire up an app. You can add new contacts, send SMS messages, make phone calls, and open the camera. Other APIs handle notifications, integration with BBM and using the PIM applications, as well as BlackBerry’s own push service.

With BlackBerry 10 vying for third place in a crowded mobile marketplace, the company has worked hard to attract and support developers. The result is one of the most open mobile platforms around, and with WebWorks one that’s accessible by anyone who’s built a web app. Taking your web applications with you wherever you go makes a lot of sense, especially with ability to take advantage of the BlackBerry features we’ve grown used to over the years, even on a new platform. Free tools (and sample code on github) make it easier to get started, using WebWorks to quickly bundle your sites up into apps – and share them with colleagues.

Free Insider Download: CITE presentations now available
Join the discussion
Be the first to comment on this article. Our Commenting Policies