CordovaFirefoxOS: Difference between revisions

(Created page with "This page is to document the development of Cordova for FirefoxOS. It is edited quite often, co ==Current issues== ===Security Exception when iterating over window.navigator...")
 
(Outdated info)
 
(63 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page is to document the development of Cordova for FirefoxOS. It is edited quite often, co
=Warning=
Consider this document outdated. For up to date content please refer to http://mozilla-cordova.github.io


==Current issues==
==API shim development==


===Security Exception when iterating over window.navigator===
{| border="1"
https://bugzilla.mozilla.org/show_bug.cgi?id=894335 - Cordova rewrites the navigator object in https://github.com/apache/cordova-js/blob/master/lib/scripts/bootstrap.js#L49. The temporary solution is to comment out https://github.com/apache/cordova-js/blob/master/lib/scripts/bootstrap.js#L67. This implies more issues, especially firing several events needs to be forced.
|-
! Cordova
! FirefoxOS
! TODO / Progress
! Status (%)
! Developer
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_accelerometer_accelerometer.md.html#Accelerometer Accelerometer]
| [https://developer.mozilla.org/en-US/docs/Web/Reference/Events/devicemotion devicemotion], [https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent.acceleration DeviceMotionEvent.acceleration]
|
| 100%
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_camera_camera.md.html#Camera Camera]
| [https://wiki.mozilla.org/WebAPI/WebActivities WebActivities], [https://hacks.mozilla.org/2013/01/introducing-web-activities/ Pick image example]
| The problematic parts are specified in [http://cordova.apache.org/docs/en/2.7.0/cordova_camera_camera.md.html#cameraOptions cameraOptions]:
* defining the source of the picture in code
* forcing encode type
* target size
* camera direction


==Comparable APIs==
Currently only the response as URI is supported
| 20%
| zalun
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_media_capture_capture.md.html#Capture Capture]
| [https://developer.mozilla.org/en-US/docs/WebAPI/Web_Activities WebActivities]
| The main differences are in the object returned to the callbacks, some on-the-fly transition will be needed.
|
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_compass_compass.md.html#Compass Compass]
| [https://developer.mozilla.org/en-US/docs/Web/Reference/Events/deviceorientation deviceorientation]
| 100%
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_connection_connection.md.html#Connection Connection]
| [https://developer.mozilla.org/en-US/docs/Web/API/window.navigator.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 [http://stackoverflow.com/questions/17494786/check-if-firefox-os-is-connected-to-wifi-for-privileged-apps Harald' answer on StackOverflow] "<code>metered</code> should be enough to tell if the user is on wifi".
|
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_contacts_contacts.md.html#Contacts 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
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_device_device.md.html#Device Device]
|
| As for the moment FxOS does not provide any info about device to not certified apps. Following properties of <code>device</code> object will not returned: <code>name</code>, <code>uuid</code>, <code>version</code>, <code>model</code>
|
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_events_events.md.html#Events Events]
|
| TBD (some of these will require a separate row in this table)
|
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_file_file.md.html#File File]
|
| TBD
|
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_geolocation_geolocation.md.html#Geolocation Geolocation]
| [https://developer.mozilla.org/en-US/docs/WebAPI/Using_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
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_globalization_globalization.md.html#Globalization Globalization]
|
| TBD
|
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser InAppBrowser]
| [https://developer.mozilla.org/en-US/docs/WebAPI/Browser Browser]
| The implementation is very different. Cordova uses <code>window.open</code> which is working in different way under FxOS. FxOS uses an <code>iframe</code> with <code>mozbrowser</code> attribute.
|
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_media_media.md.html#Media 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".
|
|
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html 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
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html#notification.beep Notification.beep]
|
| TBD
|
|
|-
| [http://cordova.apache.org/docs/en/2.7.0/cordova_notification_notification.md.html#notification.vibrate Notification.vibrate]
| [https://developer.mozilla.org/en-US/docs/Web/API/window.navigator.vibrate?redirectlocale=en-US&redirectslug=DOM%2Fwindow.navigator.vibrate Vibration]
| in review
| 99%
|
|-
| [http://cordova.apache.org/docs/en/2.7.0/cordova_splashscreen_splashscreen.md.html#Splashscreen Splashscreen]
|
| TBD
|
|
|-
| [http://cordova.apache.org/docs/en/2.7.0/cordova_storage_storage.md.html#Storage Storage]
|
| TBD
|
|
|-
|}
 
==Running an early dev version==
<pre>
$ 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
</pre>
Create a dir (possibly a bug it should be autocreated or used from another dir)
<pre>$ mkdir -p ~/.cordova/lib/firefoxos/cordova-firefoxos-dev/</pre>
Later on run <code>cordova</code> from <code>cordova-cli/bin/cordova</code>
 
==Running the latest stable cordova==
<pre>
$ npm install cordova -g
</pre>
 
Create your app:
<pre>
$ cordova create fxos-app
$ cd fxos-app
</pre>
(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:
<pre>
{
  "id":"io.cordova.hellocordova",
  "name":"HelloCordova",
  "lib": {
    "firefoxos": {
      "uri": "/full/path/to/cordova-firefoxos",
      "version": "dev",
      "id": "cordova-firefoxos-dev"
    }
  }
}
</pre>
Add Firefox OS platform
<pre>
$ cordova platform add firefoxos
</pre>
Add plugins from github or local disk
<pre>
$ cordova plugin add https://github.com/mozilla-cordova/cordova-plugin-device.git
$ cordova plugin add ../cordova-plugin-contacts
</pre>
Prepare as usual
<pre>
$ cordova prepare
</pre>
 
==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 <code>index.html</code> created after <code>cordova prepare</code> contains inline javascript. The (temporary) solution is to remove inline script and add <code>document.onload = app.initialize();</code> at the end of the <code>www/js/index.js</code> 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===
{| border="1"
|-
! Cordova
! FFOS 1.2
! FFOS 1.3
|-
| displayName
| - (name)
| name
|-
| nickname
| - (nickname)
| - (nickname)
|-
| name (entire object)
| familyName<br/>givenName<br/>- (additionalName)
| familyName<br/>givenName<br/>- (additionalName)
|-
| phoneNumbers
| tel
| tel
|-
| categories
| category
| category
|-
| emails
| email
| email
|}
 
===Searching by number===

Latest revision as of 09:21, 27 July 2015

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