Firefox vs Chrome App APIs How do the API’s compare ?

When porting a chrome packaged app to a firefox packaged app you will need to do an inventory as to which chrome specific api’s you are using and create a level of abstraction around them, as the naming / capabilities of the apis vary across the platforms.

I will try to break this article into information on  which apis are supported across both platforms, where you can find docs, and lastly which apis have no commonality across both platforms (Firefox or Chrome).

Web APIs in Common:

The Web APIs that share commonality in function between the two platforms, are listed below:

Firefox OS:
alarm, getUserMedia(audio), Bluetooth, Device Storage API, navigator.id API, Idle API, Geolocation API, Web Notifications, Permissions API, Battery Status API, Simple Push API, TCP Socket API, Pointer Lock API, Power Management API, ContextMenus

Chrome:
alarms, audio, bluetooth, events ,fileSystem, identity, idle, location, mediaGalleries, notifications, permissions, power, pushMessaging, socket, (Battery Status in Beta), contextMenus

List of Chrome’s HTML5 apis: http://developer.chrome.com/apps/api_other.html

The difficulty for the developer will be in writing an app that can handle both browsers elegantly.  This is already done in many cases with the use of W3C compliant API’s such as geolocation data.(navigator.geolocation, which is also supported under google chrome, just not listed as such in their packaged apps documentation (ack), and soon to be battery status.  But for the majority the function calls are different as well as the data being returned.

Basically this is a bit of a cluster bug until W3C steps in these APIs aren’t close enough to easily describe all the differences in one document.  The best case scenario is if you are only using a subset of the above APIs and you manually code an abstraction layer, or use an intervening javascript framework like phonegap which would make the interfaces of less consequence to the developer.

The other part of the discussion could revolve around which Firefox OS API’s are not yet implemented in Chrome OS. How close are all the APIs to standardization ?

WebFM API, Vibration API,  Camera API, Power Management API, Proximity API, Time/Clock API, Ambient Light Sensor API, Device Orientation API, Screen Orientation APIWeb Activities,

Chrome OS similarly has a set of APIs which are not implemented in Firefox OS:

app.window = a concept not supported in firefox, generally gives the ability to maximize, minimize, change window size..etc

app.runtime = a concept not supported in firefox, basically used to notify when the app has been restarted

i18n = internationalization API.

serial= An API that allows you to read contents of the serial port.

runtime = API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle.

system.cpu, system.display, system.memory , system.storage = There are mechanisms to get some of these stats, but not all of them in firefox os.

tts: Text To Speech API

usb: An API that allows you to access USB based devices

Read More »

Rockin’ the Free Web – How to Convert a chrome packaged app to a Firefox OS packaged App

I saw a question on a thread this week, and decided to spend a few hours to write up the process, as well as provide an example.

This bug will cover the general conversion process, but it doesn’t cover all the idiosyncrasies / differences between the two platforms.

The example I’m going to use for the conversion is from the google chrome sample app repository:

The most basic example I have already converted to a packaged app the Hello World example.

For the most basic app that I have converted “Hello World”, we look at the following pieces and how they differ / can also possibly coexist between the two platforms.

manifest.json:

 {  "manifest_version": 2,
    "name": "Hello World",
    "version": "2",
    "minimum_chrome_version": "23",
    "icons": {
         "16": "icon_16.png",
         "128": "icon_128.png"
     },
     "app": {
         "background": {
         "scripts": ["main.js"]
         }
      }
   }

manifest.webapp:

 {  "name": "Hello World",
    "description": "Hello World",
    "launch_path": "/index.html",
    "icons": {
        "128": "icon_128.png",
        "16": "icon_16.png"
    },
    "developer": {
        "name": "David Clarke",
        "url": "https://github.com/onecyrenus/firefox-os-apps"
    },
    "default_locale": "en",
    "permissions": {
    }
 }

The main difference between these two loading mechanisms is just file structure, and some syntactic sugar.  So why not deploy a manifest.json and start rocking the free web !!!