CordovaFirefoxOS: Difference between revisions

(Outdated info)
 
(38 intermediate revisions by 2 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
==General issues==
 
====Security Exception when iterating over window.navigator====
* [https://bugzilla.mozilla.org/show_bug.cgi?id=894335 Cordova rewrites the navigator object].
** 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.
** It is no longer the case for FirefoxOS 1.2.0. Further investigation is needed as onCordovaConnectionReady is still not fired.


==API shim development==
==API shim development==
Line 14: Line 8:
! Cordova
! Cordova
! FirefoxOS
! FirefoxOS
! What's left
! TODO / Progress
! Status (%)
! Status (%)
! Developer
! Developer
Line 20: Line 14:
| [http://cordova.apache.org/docs/en/3.0.0/cordova_accelerometer_accelerometer.md.html#Accelerometer Accelerometer]
| [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]
| [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]
| Cordova provides <code>getCurrentAcceleration</code> and <code>watchAcceleration</code>. This is easy to simulate using <code>DeviceMotionEvent</code>. <code>getCurrentAcceleration</code> will simply call it once and clear the watcher afterwards. The only advantage will be the <code>acceleratorOptions</code> which contains <code>frequency</code> property. There is also a <code>timestamp</code> property returned to Cordova's callback.
|  
|  
| 100%
|  
|  
|-
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_camera_camera.md.html#Camera Camera]
| [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]
| [https://wiki.mozilla.org/WebAPI/WebActivities WebActivities], [https://hacks.mozilla.org/2013/01/introducing-web-activities/ Pick image example]
| FirefoxOS is providing access to pictures via WebActivities. Usage is fairly simple and an example is already working. However full support of Cordova API will be hard (or impossible) to implement. The problematic parts are specified in [http://cordova.apache.org/docs/en/2.7.0/cordova_camera_camera.md.html#cameraOptions cameraOptions]:  
| 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  
* defining the source of the picture in code  
* forcing encode type
* forcing encode type
* target size
* target size
* camera direction
* camera direction
|  
 
|  
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]
| [http://cordova.apache.org/docs/en/3.0.0/cordova_media_capture_capture.md.html#Capture Capture]
Line 42: Line 38:
| [http://cordova.apache.org/docs/en/3.0.0/cordova_compass_compass.md.html#Compass Compass]
| [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]
| [https://developer.mozilla.org/en-US/docs/Web/Reference/Events/deviceorientation deviceorientation]
| FirefoxOS provides support as an event. Use <code>absolute</code> parameter to check if the device is able to provide the Earth coordinate frame 
|  
|  
| 100%
|  
|  
|-
|-
Line 54: Line 50:
| [http://cordova.apache.org/docs/en/3.0.0/cordova_contacts_contacts.md.html#Contacts Contacts]
| [http://cordova.apache.org/docs/en/3.0.0/cordova_contacts_contacts.md.html#Contacts Contacts]
| [[WebAPI/ContactsAPI]]
| [[WebAPI/ContactsAPI]]
| There are lacks in FxOS documentation of Contact fields (<code>impp</code>, <code>url</code>, <code>address</code>). Some fields are not exactly corresponding to each other. FxOS has an ability to save only one organization. Cordova has no info about (<code>anniversary</code>, <code>sex</code>, <code>genderIdentity</code>)
| 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]
| [http://cordova.apache.org/docs/en/3.0.0/cordova_device_device.md.html#Device Device]
Line 78: Line 74:
| [http://cordova.apache.org/docs/en/3.0.0/cordova_geolocation_geolocation.md.html#Geolocation Geolocation]
| [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]
| [https://developer.mozilla.org/en-US/docs/WebAPI/Using_geolocation Using geolocation]
| The only difference is providing a timestamp as Date object
| 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]
| [http://cordova.apache.org/docs/en/3.0.0/cordova_globalization_globalization.md.html#Globalization Globalization]
Line 100: Line 96:
|  
|  
|-
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html#notification.alert Notification.alert]
| [http://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html Notification]
| [https://developer.mozilla.org/en-US/docs/Web/API/window.alert window.alert]
|  
| UI
| 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.)
| 90%
| 99%
| zalun
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html#notification.confirm Notification.confirm]
| [https://developer.mozilla.org/en-US/docs/Web/API/window.confirm window.confirm]
| UI
| 90%
| zalun
|-
| [http://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html#notification.prompt Notification.prompt]
| [https://developer.mozilla.org/en-US/docs/Web/API/window.prompt window.prompt]
| UI
| 90%
| zalun
| zalun
|-
|-
Line 126: Line 110:
| [http://cordova.apache.org/docs/en/2.7.0/cordova_notification_notification.md.html#notification.vibrate Notification.vibrate]
| [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]
| [https://developer.mozilla.org/en-US/docs/Web/API/window.navigator.vibrate?redirectlocale=en-US&redirectslug=DOM%2Fwindow.navigator.vibrate Vibration]
| None
| in review
|  
| 99%
|  
|  
|-
|-
Line 143: Line 127:
|-
|-
|}
|}
==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