Firefox OS Now With Cordova Support
Written by Ian Elliot   
Monday, 24 February 2014

This sounds crazy. Cordova, aka PhoneGap, is a system that allows web apps to run on mobile phones as native apps. Now Cordova supports Firefox OS. But Firefox OS native apps are web apps. What's the point?

It might seem crazy but this is a very clever move.

First it is worth making it clear that the Cordova support does not in some way convert Firefox OS web apps into "native" apps as a number of reports suggest.

Firefox OS "native" apps are web apps and Cordova apps targeting Firefox OS are just HTML/JavaScript/CSS based apps.

 

 

Firefox OS is attempting to build a standards-based API that will allow web apps, i.e. built using nothing but JavaScript, HTML and CSS, to run with the same access to the hardware as a native app.

Firefox OS either doesn't have native apps or web apps are its native apps, depending on how you look at it. 

The problem is that the standards are slow to evolve and it is something of a struggle to keep up with how things should be implemented. Also many of the standards are not implemented on other platforms, so building a web app for Firefox OS doesn't make it easy to port the app to other, perhaps more profitable, devices.

This means that Firefox OS has a slight problem acquiring the number of apps it needs to look credible in the market. 

This is where Apache Cordova comes in. 

On other mobile phones Cordova takes your web app and wraps it in a container that is a standard native app for that particular phone. The native container acts like a web browser for the HTML/JavaScript code.

In addition Cordova provides a range of special APIs that allow the JavaScript to interact with the phone's hardware and other systems at a level that would be impossible in a standard browser.  That is, the container loads and displays the web app and takes care of interfacing any JavaScript API calls that make use of the phone. 

This is a clever idea and you could think of it as providing a web app based OS within the original OS of the phone. 

The key to Cordova's importance to Firefox OS is that to write a Cordova app you make use of its well-defined APIs. If you want to access the camera, say, you call the camera object's getPicture method with a callback that makes use of the bitmap returned:

navigator.camera.getPicture(function (src) {
do something with the picture returned in src
});

This call is the same for all of the phones that Cordova supports.

Now consider doing the same job in Firefox OS. You either have to work out how to use a Web Activity or you wait until the full camera API, which is part of WebRTC, is complete. No matter how you implement the picture taking, it almost certainly won't work on any other phone as a native app and it isn't likely to work as a web app until mobile browsers catch up with the  WebAPIs that Mozilla is creating.

 

cordovaffos

 

What this all means is that you can use the Cordova APIs to write a web app that will run on Firefox OS with the help of a translation layer and on all of the other phones that are supported as native apps. 

This seems like a much better prospect.

Not only can you write new Cordova/Firefox OS apps, but existing Cordova apps should just work on Firefox OS with a minor addition. 

So keen on this idea is Mozilla that they have extended their "phones for apps" scheme to target Cordova apps. If you have an existing Cordova app you can show it to Mozilla and if they like it they will give you a Firefox phone to use help you make it run on Firefox OS. 

This is all very practical, but it does send the message that the HTML5 standards-based APIs that Mozilla and others are working on are just not up to the job at the moment and that Cordova's APIs are a de facto standard.

You may not like this conclusion but at the moment it seems to be true.

PhoneGapIcon

More Information

Building Cordova apps for Firefox OS

Phones for Cordova/PhoneGap Ports application.

Related Articles

Firefox OS Moves To 1.1  

More Support For Firefox OS   

ZTE To Sell Firefox Phones On e-Bay

Firefox Phones Go On Sale, Marketplace Opens

Getting Started With Firefox OS And Geeksphone Keon    

Getting Started with Firefox OS - The UX Building Blocks  

Getting started with PhoneGap

    

 

To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, FacebookGoogle+ or Linkedin,  or sign up for our weekly newsletter.

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info

 

Banner


AI Breakthrough For Robot Surgery
17/11/2024

Using imitation learning, a robot has learned to perform surgical procedures as skillfully as human surgeons, bringing the field of robotic surgery closer to true autonomy.



Sequin - Open Source Message Stream Built On Postgres
31/10/2024

Sequin is a tool for capturing changes and streaming data out of your Postgres database, guaranteeing exactly once processing. What does that mean?


More News

 

Last Updated ( Monday, 24 February 2014 )