cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Maj <>
Subject Re: onNativeReady and FirefoxOS
Date Mon, 01 Jul 2013 19:43:35 GMT
Hey Piotr,

Most Cordova platforms include two "stacks": a native and a web stack, or
side, or context. For example, Android and iOS implement various bits of
functionality (like access to contacts data) by bridging into the native
SDK APIs and making native calls, then sending messages back into the web
context to return the requested data.

It is up to each platform's implementation to expose an `exec` method,
which is an interface between the web and native contexts. It is a
message-passing mechanism. You invoke it from JavaScript, passing in a few
arguments that map themselves to native classes/methods, as well as
success and failure callbacks. Cordova will then marshall these `exec`
calls to the native context, make sure the message gets passed into the
appropriate native API class and method, and, once complete, makes sure
the appropriate success or failure callback gets invoked back in the web
context. More information on this method can be found in our Plugin
Development guide [1].

Some Cordova platforms, like BlackBerry, FxOS and Tizen, are purely
web-based, and thus have no "native" side. Instead, these platforms
already have JavaScript-based device APIs exposed. For most of these
platforms, the `exec` method doesn't marshall to a native context but
instead simply invokes the appropriate JavaScript method provided by the
platform. This keeps cordova's `exec` abstraction intact and thus enables
development of Cordova plugins to be done in a cross-platform manner:
JavaScript serves as the abstraction.

Firefox OS should be doing something similar to BlackBerry or Tizen. For
one example, BlackBerry has a short list of purely-JavaScript plugins [2],
and if the `exec` method invocation detects that an exec call is for one
of these plugins, it will simply invoke that JS-only plugin's method as
appropriate [3]. Similarly, Tizen has an exec method implementation that
simply invokes a "manager" class [4], which in turn literally translates
into a purely JavaScript require call for the particular service+action
invoked and lets that JavaScript method do all of the work [5]. In my
opinion, FxOS' implementation will mirror Tizen's closely, since all of
FxOS APIs are available in JavaScript. Perhaps there is a "native"
component to FxOS (I am not super familiar with FxOS internals) down the
road, where Cordova users will want to invoke some FxOS-specific low-level
APIs through some mechanism.

Hopefully that can help you out. Feel free to post more q's or contact me
directly if there's anything I can help with.


On 7/1/13 10:05 AM, "Piotr Zalewa" <> wrote:

>now It's stuck on events which are waiting for initialization (in array
>xos.js#L5976 - onCordovaReady and onCordovaConnectionReady.
>onCordovaReady is fired, but onCordovaConnectionReady is not.
>The connection ready event is fired in
>xos.js#L5379-L5410 but this code isn't run and hence it's not called when
>cordova ready is fired.
>Any solution for this?
>----- Original Message -----
>From: "Gord Tanner" <>
>Sent: Tuesday, June 25, 2013 5:38:01 PM
>Subject: Re: onNativeReady and FirefoxOS
>I could have swore there was one at one point ;)
>but it is going to look exactly like the webos one [1]
>[1] -
>On Tue, Jun 25, 2013 at 10:52 AM, Andrew Grieve
>> likely you want to add a bootstrap.firefoxos.js file
>> On Tue, Jun 25, 2013 at 3:40 AM, Piotr Zalewa <>
>> > Hi,
>> >
>> > Here is me again.
>> >
>> > I commented out the "reinstantiating" window.navigator to make it not
>> > throw SecurityError under FxOS.
>> >
>> > I then realized the 'deviceready' isn't fired.
>> > It should be fired in
>> >
>>oxos.js#L5977afterchannel.onDOMContentLoaded, channel.onNativeReady,
>> > channel.onPluginsReady.
>> > onDOMContentLoaded and onPluginsReady are fired, but onNativeReady is
>> not.
>> >
>> > The only place in this file which is related to this event is this:
>> >
>> >
>> >     // _nativeReady is global variable that the native side can set
>> >     // to signify that the native code is ready. It is a global since
>> >     // it may be called before any cordova JS is ready.
>> >     if (window._nativeReady) {
>> >;
>> >     }
>> >
>> > Is this event not fired because of my change to cordova-firefoxos.js
>> > (commenting out
>> >
>> > )?
>> >
>> > Please help
>> > zalun
>> >
>> > PS.
>> > There is also an issue later on with onCordovaConnectionReady (but I
>> > forced onNativeReady before, so too many variables to play)
>> >

View raw message