You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Juan Cruz Viotti <ju...@gmail.com> on 2014/08/06 04:15:21 UTC

Access config.xml preferences from the JavaScript side of a plugin

Hi everyone,

I’ve stumbled in the situation where I want to read the value of a preference present in config.xml from the JavaScript side of a Cordova plugin. 

My current approach is the following:

-  Create a native service (iOS in this case) with a method called `getPreference` which queries `self.commandDelegate.settings`.
- Wait on the `deviceready` event from the plugin’s JavaScript file.
- Call `getPreference` with `cordova.exec`.

I’d like to avoid this complexity and overhead and just be able to query the preferences from the JavaScript side of the plugin, without depending on the native side.

I’ve created a StackOverflow question (http://stackoverflow.com/questions/24939920/access-config-xml-preferences-from-javascript-plugins) some time ago (tagged as Cordova) but it was never answered. I’ve also found a very similar question that wasn’t answered neither: http://stackoverflow.com/questions/22744269/is-there-a-cordova-plugin-to-read-values-from-config-xml?lq=1.

I’ve looked at Cordova modules such as argscheck, channel, utils, etc in the GitHub repo (https://github.com/apache/cordova-js) however I couldn’t find what I’m looking for.

Can someone point me in the right direction?

Thanks a lot in advance.

Regards,

---
Juan Cruz Viotti, Software Engineer
juanchiviotti@gmail.com








Re: Access config.xml preferences from the JavaScript side of a plugin

Posted by Michal Mocny <mm...@chromium.org>.
David once wrote a plugin that sounds exactly like what you describe:
https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings

Just throwing that out there.


On Wed, Aug 6, 2014 at 1:44 AM, Andrey Kurdumov <ka...@googlemail.com>
wrote:

> There was thread in the mailing archive where this questions was discussed:
> https://www.mail-archive.com/dev@cordova.apache.org/msg14313.html
>
>
> 2014-08-06 11:40 GMT+06:00 Marc Weiner <mh...@gmail.com>:
>
> > What about a pre-build hook that parses the config.xml file and
> generates a
> > config.js file, with a "CorodvaPrefs" or similar object?
> >
> > Marc
> >
> >
> > On Tue, Aug 5, 2014 at 10:15 PM, Juan Cruz Viotti <
> juanchiviotti@gmail.com
> > >
> > wrote:
> >
> > > Hi everyone,
> > >
> > > I’ve stumbled in the situation where I want to read the value of a
> > > preference present in config.xml from the JavaScript side of a Cordova
> > > plugin.
> > >
> > > My current approach is the following:
> > >
> > > -  Create a native service (iOS in this case) with a method called
> > > `getPreference` which queries `self.commandDelegate.settings`.
> > > - Wait on the `deviceready` event from the plugin’s JavaScript file.
> > > - Call `getPreference` with `cordova.exec`.
> > >
> > > I’d like to avoid this complexity and overhead and just be able to
> query
> > > the preferences from the JavaScript side of the plugin, without
> depending
> > > on the native side.
> > >
> > > I’ve created a StackOverflow question (
> > >
> >
> http://stackoverflow.com/questions/24939920/access-config-xml-preferences-from-javascript-plugins
> > )
> > > some time ago (tagged as Cordova) but it was never answered. I’ve also
> > > found a very similar question that wasn’t answered neither:
> > >
> >
> http://stackoverflow.com/questions/22744269/is-there-a-cordova-plugin-to-read-values-from-config-xml?lq=1
> > > .
> > >
> > > I’ve looked at Cordova modules such as argscheck, channel, utils, etc
> in
> > > the GitHub repo (https://github.com/apache/cordova-js) however I
> > couldn’t
> > > find what I’m looking for.
> > >
> > > Can someone point me in the right direction?
> > >
> > > Thanks a lot in advance.
> > >
> > > Regards,
> > >
> > > ---
> > > Juan Cruz Viotti, Software Engineer
> > > juanchiviotti@gmail.com
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
>

Re: Access config.xml preferences from the JavaScript side of a plugin

Posted by Andrey Kurdumov <ka...@googlemail.com>.
There was thread in the mailing archive where this questions was discussed:
https://www.mail-archive.com/dev@cordova.apache.org/msg14313.html


2014-08-06 11:40 GMT+06:00 Marc Weiner <mh...@gmail.com>:

> What about a pre-build hook that parses the config.xml file and generates a
> config.js file, with a "CorodvaPrefs" or similar object?
>
> Marc
>
>
> On Tue, Aug 5, 2014 at 10:15 PM, Juan Cruz Viotti <juanchiviotti@gmail.com
> >
> wrote:
>
> > Hi everyone,
> >
> > I’ve stumbled in the situation where I want to read the value of a
> > preference present in config.xml from the JavaScript side of a Cordova
> > plugin.
> >
> > My current approach is the following:
> >
> > -  Create a native service (iOS in this case) with a method called
> > `getPreference` which queries `self.commandDelegate.settings`.
> > - Wait on the `deviceready` event from the plugin’s JavaScript file.
> > - Call `getPreference` with `cordova.exec`.
> >
> > I’d like to avoid this complexity and overhead and just be able to query
> > the preferences from the JavaScript side of the plugin, without depending
> > on the native side.
> >
> > I’ve created a StackOverflow question (
> >
> http://stackoverflow.com/questions/24939920/access-config-xml-preferences-from-javascript-plugins
> )
> > some time ago (tagged as Cordova) but it was never answered. I’ve also
> > found a very similar question that wasn’t answered neither:
> >
> http://stackoverflow.com/questions/22744269/is-there-a-cordova-plugin-to-read-values-from-config-xml?lq=1
> > .
> >
> > I’ve looked at Cordova modules such as argscheck, channel, utils, etc in
> > the GitHub repo (https://github.com/apache/cordova-js) however I
> couldn’t
> > find what I’m looking for.
> >
> > Can someone point me in the right direction?
> >
> > Thanks a lot in advance.
> >
> > Regards,
> >
> > ---
> > Juan Cruz Viotti, Software Engineer
> > juanchiviotti@gmail.com
> >
> >
> >
> >
> >
> >
> >
> >
>

Re: Access config.xml preferences from the JavaScript side of a plugin

Posted by Marc Weiner <mh...@gmail.com>.
What about a pre-build hook that parses the config.xml file and generates a
config.js file, with a "CorodvaPrefs" or similar object?

Marc


On Tue, Aug 5, 2014 at 10:15 PM, Juan Cruz Viotti <ju...@gmail.com>
wrote:

> Hi everyone,
>
> I’ve stumbled in the situation where I want to read the value of a
> preference present in config.xml from the JavaScript side of a Cordova
> plugin.
>
> My current approach is the following:
>
> -  Create a native service (iOS in this case) with a method called
> `getPreference` which queries `self.commandDelegate.settings`.
> - Wait on the `deviceready` event from the plugin’s JavaScript file.
> - Call `getPreference` with `cordova.exec`.
>
> I’d like to avoid this complexity and overhead and just be able to query
> the preferences from the JavaScript side of the plugin, without depending
> on the native side.
>
> I’ve created a StackOverflow question (
> http://stackoverflow.com/questions/24939920/access-config-xml-preferences-from-javascript-plugins)
> some time ago (tagged as Cordova) but it was never answered. I’ve also
> found a very similar question that wasn’t answered neither:
> http://stackoverflow.com/questions/22744269/is-there-a-cordova-plugin-to-read-values-from-config-xml?lq=1
> .
>
> I’ve looked at Cordova modules such as argscheck, channel, utils, etc in
> the GitHub repo (https://github.com/apache/cordova-js) however I couldn’t
> find what I’m looking for.
>
> Can someone point me in the right direction?
>
> Thanks a lot in advance.
>
> Regards,
>
> ---
> Juan Cruz Viotti, Software Engineer
> juanchiviotti@gmail.com
>
>
>
>
>
>
>
>