CordovaFirefoxOS

From MozillaWiki
Jump to: navigation, search

Warning

Consider this document outdated. For up to date content please refer to http://mozilla-cordova.github.io

API shim development

Cordova FirefoxOS TODO / Progress Status (%) Developer
Accelerometer devicemotion, DeviceMotionEvent.acceleration 100%
Camera WebActivities, Pick image example The problematic parts are specified in cameraOptions:
  • defining the source of the picture in code
  • forcing encode type
  • target size
  • camera direction

Currently only the response as URI is supported

20% zalun
Capture WebActivities The main differences are in the object returned to the callbacks, some on-the-fly transition will be needed.
Compass deviceorientation 100%
Connection navigator.connection Cordova has a different object under the same navigator property name. FirefoxOS doesn't provide type of the connection to the apps. According to Harald' answer on StackOverflow "metered should be enough to tell if the user is on wifi".
Contacts WebAPI/ContactsAPI Some fields are not exactly corresponding to each other. Some information might be lost if contact is saved by Cordova based app. Awaiting merge to Cordova dev version. 99% zalun
Device As for the moment FxOS does not provide any info about device to not certified apps. Following properties of device object will not returned: name, uuid, version, model
Events TBD (some of these will require a separate row in this table)
File TBD
Geolocation Using geolocation Waiting for "resolved flag". CLI (prepare method) needs to have a new functionality - adding permissions to manifest.json - needs to be configurable, so user will be able to write description 99% Herm, zalun, jlongster
Globalization TBD
InAppBrowser Browser The implementation is very different. Cordova uses window.open which is working in different way under FxOS. FxOS uses an iframe with mozbrowser attribute.
Media Playing and recording music files. "The current implementation does not adhere to a W3C specification for media capture, and is provided for convenience only. A future implementation will adhere to the latest W3C specification and may deprecate the current APIs".
Notification There is an issue with copying resources (CSS, PNG) when adding the plugin. (There is also no way of automatically adding the CSS file to HTML, which to me looks more like a feature.) 99% zalun
Notification.beep TBD
Notification.vibrate Vibration in review 99%
Splashscreen TBD
Storage TBD

Running an early dev version

$ git clone https://github.com/mozilla-cordova/cordova-cli.git
$ cd cordova-cli && npm install
$ cd ..
$ git clone https://github.com/apache/cordova-plugman.git
$ cd cordova-plugman && git checkout ffos
$ cd ..
$ cd cordova-cli && npm install ../cordova-plugman
$ cd ..
$ git clone https://github.com/mozilla-cordova/cordova-firefoxos.git

Create a dir (possibly a bug it should be autocreated or used from another dir)

$ mkdir -p ~/.cordova/lib/firefoxos/cordova-firefoxos-dev/

Later on run cordova from cordova-cli/bin/cordova

Running the latest stable cordova

$ npm install cordova -g

Create your app:

$ cordova create fxos-app
$ cd fxos-app

(optional) To use a local copy of cordova-firefoxos platform code, create a file named .cordova/config.json under the root folder of your app with the following content, replacing app id, name and full path to cordova-firefoxos as needed:

{
  "id":"io.cordova.hellocordova",
  "name":"HelloCordova",
  "lib": {
    "firefoxos": {
      "uri": "/full/path/to/cordova-firefoxos",
      "version": "dev",
      "id": "cordova-firefoxos-dev"
    }
  }
}

Add Firefox OS platform

$ cordova platform add firefoxos

Add plugins from github or local disk

$ cordova plugin add https://github.com/mozilla-cordova/cordova-plugin-device.git
$ cordova plugin add ../cordova-plugin-contacts

Prepare as usual

$ cordova prepare

Manifest issues

Manifest is automatically created with every ``cordova prepare``. There should be a mechanism to provide these values in a configuration file.

Privileged issue

Default index.html created after cordova prepare contains inline javascript. The (temporary) solution is to remove inline script and add document.onload = app.initialize(); at the end of the www/js/index.js file.

Comparing Contacts find/search API

Fields in both APIs are different there are differences in the search API as well. There are also differences between versions of FFOS (1.2 and 1.3).

Searching by text fields

Cordova FFOS 1.2 FFOS 1.3
displayName - (name) name
nickname - (nickname) - (nickname)
name (entire object) familyName
givenName
- (additionalName)
familyName
givenName
- (additionalName)
phoneNumbers tel tel
categories category category
emails email email

Searching by number