You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Axel Nennker <ig...@gmail.com> on 2015/02/10 16:24:26 UTC

Does this plugin support the current platform?

Hi,

is there a way how an app can determine whether a plugin supports the
current  platform?

E.g.: the barcodescanner plugin is not supporting firefoxos
How could an app know that which out hardcoding this into the app?

If there is a standard way in Cordova then this is a userland question.
If not then this is a feature request to add this info to e.g.
cordova/plugin_list exports.metadata ?!

-Axel

Re: Does this plugin support the current platform?

Posted by Michal Mocny <mm...@chromium.org>.
Generally, this is a bit of an unsolved problem.

While plugins have platform tags, I believe we install all plugins for all
platforms.  This is because the platform tag was used for optional
configuration initially and was never mandated.  So, you can use that as a
signal which says "should support platform x" but there are surely examples
of plugins that blindly added all platform tags, and plugins which haven't
added any platform tags at all, yet support some platforms.

With feature detection, this will only work if the plugin has not blindly
clobbered the js api for all platforms (which isn't uncommon).  Some
plugins provide no-op stubs, or just execute calls that won't work.

Not quite sure we gave enough guidance on proper multi-platform plugin
development, and some of the guidance we are still just learning.

-Michal


On Tue, Feb 10, 2015 at 12:18 PM, Horn, Julian C <ju...@intel.com>
wrote:

> The natural way to determine whether some functionality is available is to
> use the "feature detection" pattern.  That is, if you want to call some
> function normally found at "myobj.myfunc", you write code like this:
>
> If (myobj && (typeof myobj.myfunc === 'function')) ...
>
> For this to work you must take care to remove plugins that don't support
> your platform before you build for that platform.  For example, before you
> build for firefoxos, you must remove the barcodescanner plugin (and then
> add it back when you build for supported platforms).  Granted, this is
> awkward, but I think it's worse to read the package.json file.
>
> Really the CLI should make the feature detection pattern work without
> having to exclude plugins on unsupported platforms.  That is, if a plugin
> doesn't support a platform, then it should contribute nothing when you
> build for that platform.
>
>     Julian
>
> -----Original Message-----
> From: Axel Nennker [mailto:ignisvulpis@gmail.com]
> Sent: Tuesday, February 10, 2015 11:48 AM
> To: dev
> Subject: Re: Does this plugin support the current platform?
>
> And then the app has to load that package.json ?
> On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:
>
> > Plugin.xml has a platforms tag for what platforms it supports. That
> > info gets uploaded to the Cordova plugins registry when publishing.
> >
> > Soon this info will be available in package.json file each plugin has.
> > On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > is there a way how an app can determine whether a plugin supports
> > > the current  platform?
> > >
> > > E.g.: the barcodescanner plugin is not supporting firefoxos How
> > > could an app know that which out hardcoding this into the app?
> > >
> > > If there is a standard way in Cordova then this is a userland question.
> > > If not then this is a feature request to add this info to e.g.
> > > cordova/plugin_list exports.metadata ?!
> > >
> > > -Axel
> > >
> >
>

RE: Does this plugin support the current platform?

Posted by "Horn, Julian C" <ju...@intel.com>.
I like it!

-----Original Message-----
From: agrieve@google.com [mailto:agrieve@google.com] On Behalf Of Andrew Grieve
Sent: Tuesday, February 10, 2015 3:52 PM
To: dev
Subject: Re: Does this plugin support the current platform?

Strawman:

If plugin.xml has *any* <platform>s, then only apply global tags to those platforms.
If plugin.xml has *no* <platform>s, then apply global tags to all platforms.

On Tue, Feb 10, 2015 at 2:18 PM, Tommy Williams <to...@devgeeks.org> wrote:

> This won't actually help right now, but that feature detection would 
> actually be possible if the plugin's "clobbers" was always a child of 
> the "platform" in plugin.xml.
>
> Right now, most plugins have their clobbers global to all platforms, 
> supported or not. If the clobbers is a child of the platform, then the 
> relevant js function/object would be undefined on an unsupported platform.
>
> This practice would also help in a situation where you might want 
> different plugins for different platforms, but exposing similar 
> functionality on one clobbered function/object (eg: the popular 
> barcode scanner plugin + the blackberry barcode scanner plugin).
>
> Unfortunately, most plugins don't do this, even though it is possible.
> The natural way to determine whether some functionality is available 
> is to use the "feature detection" pattern.  That is, if you want to 
> call some function normally found at "myobj.myfunc", you write code like this:
>
> If (myobj && (typeof myobj.myfunc === 'function')) ...
>
> For this to work you must take care to remove plugins that don't 
> support your platform before you build for that platform.  For 
> example, before you build for firefoxos, you must remove the 
> barcodescanner plugin (and then add it back when you build for 
> supported platforms).  Granted, this is awkward, but I think it's worse to read the package.json file.
>
> Really the CLI should make the feature detection pattern work without 
> having to exclude plugins on unsupported platforms.  That is, if a 
> plugin doesn't support a platform, then it should contribute nothing 
> when you build for that platform.
>
>     Julian
>
> -----Original Message-----
> From: Axel Nennker [mailto:ignisvulpis@gmail.com]
> Sent: Tuesday, February 10, 2015 11:48 AM
> To: dev
> Subject: Re: Does this plugin support the current platform?
>
> And then the app has to load that package.json ?
> On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:
>
> > Plugin.xml has a platforms tag for what platforms it supports. That 
> > info gets uploaded to the Cordova plugins registry when publishing.
> >
> > Soon this info will be available in package.json file each plugin has.
> > On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > is there a way how an app can determine whether a plugin supports 
> > > the current  platform?
> > >
> > > E.g.: the barcodescanner plugin is not supporting firefoxos How 
> > > could an app know that which out hardcoding this into the app?
> > >
> > > If there is a standard way in Cordova then this is a userland question.
> > > If not then this is a feature request to add this info to e.g.
> > > cordova/plugin_list exports.metadata ?!
> > >
> > > -Axel
> > >
> >
>

Re: Does this plugin support the current platform?

Posted by Axel Nennker <ig...@gmail.com>.
Created a JIRA issue to implement Andrew's strawman
https://issues.apache.org/jira/browse/CB-8461



2015-02-11 1:27 GMT+01:00 Michal Mocny <mm...@chromium.org>:

> Indeed.  No platform tag kinda implies js-only plugin, so captures the
> spirit of the intent well!
>
> On Tue, Feb 10, 2015 at 5:11 PM, Steven Gill <st...@gmail.com>
> wrote:
>
> > Sounds like a smart change.
> > On Feb 10, 2015 2:10 PM, "tommy-carlos williams" <to...@devgeeks.org>
> > wrote:
> >
> > > Nice
> > >
> > > +1
> > >
> > > One change in Cordova is a lot bette than expecting all plugins to
> change
> > > ;)
> > >
> > >
> > > --
> > > tommy-carlos williams
> > >
> > > On 11 February 2015 at 07:54:17, Andrew Grieve (agrieve@chromium.org)
> > > wrote:
> > >
> > > Strawman:
> > >
> > > If plugin.xml has *any* <platform>s, then only apply global tags to
> those
> > > platforms.
> > > If plugin.xml has *no* <platform>s, then apply global tags to all
> > > platforms.
> > >
> > > On Tue, Feb 10, 2015 at 2:18 PM, Tommy Williams <to...@devgeeks.org>
> > > wrote:
> > >
> > > > This won't actually help right now, but that feature detection would
> > > > actually be possible if the plugin's "clobbers" was always a child of
> > the
> > > > "platform" in plugin.xml.
> > > >
> > > > Right now, most plugins have their clobbers global to all platforms,
> > > > supported or not. If the clobbers is a child of the platform, then
> the
> > > > relevant js function/object would be undefined on an unsupported
> > > platform.
> > > >
> > > > This practice would also help in a situation where you might want
> > > different
> > > > plugins for different platforms, but exposing similar functionality
> on
> > > one
> > > > clobbered function/object (eg: the popular barcode scanner plugin +
> the
> > > > blackberry barcode scanner plugin).
> > > >
> > > > Unfortunately, most plugins don't do this, even though it is
> possible.
> > > > The natural way to determine whether some functionality is available
> is
> > > to
> > > > use the "feature detection" pattern. That is, if you want to call
> some
> > > > function normally found at "myobj.myfunc", you write code like this:
> > > >
> > > > If (myobj && (typeof myobj.myfunc === 'function')) ...
> > > >
> > > > For this to work you must take care to remove plugins that don't
> > support
> > > > your platform before you build for that platform. For example, before
> > you
> > > > build for firefoxos, you must remove the barcodescanner plugin (and
> > then
> > > > add it back when you build for supported platforms). Granted, this is
> > > > awkward, but I think it's worse to read the package.json file.
> > > >
> > > > Really the CLI should make the feature detection pattern work without
> > > > having to exclude plugins on unsupported platforms. That is, if a
> > plugin
> > > > doesn't support a platform, then it should contribute nothing when
> you
> > > > build for that platform.
> > > >
> > > > Julian
> > > >
> > > > -----Original Message-----
> > > > From: Axel Nennker [mailto:ignisvulpis@gmail.com]
> > > > Sent: Tuesday, February 10, 2015 11:48 AM
> > > > To: dev
> > > > Subject: Re: Does this plugin support the current platform?
> > > >
> > > > And then the app has to load that package.json ?
> > > > On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com>
> wrote:
> > > >
> > > > > Plugin.xml has a platforms tag for what platforms it supports. That
> > > > > info gets uploaded to the Cordova plugins registry when publishing.
> > > > >
> > > > > Soon this info will be available in package.json file each plugin
> > has.
> > > > > On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com>
> > wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > is there a way how an app can determine whether a plugin supports
> > > > > > the current platform?
> > > > > >
> > > > > > E.g.: the barcodescanner plugin is not supporting firefoxos How
> > > > > > could an app know that which out hardcoding this into the app?
> > > > > >
> > > > > > If there is a standard way in Cordova then this is a userland
> > > question.
> > > > > > If not then this is a feature request to add this info to e.g.
> > > > > > cordova/plugin_list exports.metadata ?!
> > > > > >
> > > > > > -Axel
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Does this plugin support the current platform?

Posted by Michal Mocny <mm...@chromium.org>.
Indeed.  No platform tag kinda implies js-only plugin, so captures the
spirit of the intent well!

On Tue, Feb 10, 2015 at 5:11 PM, Steven Gill <st...@gmail.com> wrote:

> Sounds like a smart change.
> On Feb 10, 2015 2:10 PM, "tommy-carlos williams" <to...@devgeeks.org>
> wrote:
>
> > Nice
> >
> > +1
> >
> > One change in Cordova is a lot bette than expecting all plugins to change
> > ;)
> >
> >
> > --
> > tommy-carlos williams
> >
> > On 11 February 2015 at 07:54:17, Andrew Grieve (agrieve@chromium.org)
> > wrote:
> >
> > Strawman:
> >
> > If plugin.xml has *any* <platform>s, then only apply global tags to those
> > platforms.
> > If plugin.xml has *no* <platform>s, then apply global tags to all
> > platforms.
> >
> > On Tue, Feb 10, 2015 at 2:18 PM, Tommy Williams <to...@devgeeks.org>
> > wrote:
> >
> > > This won't actually help right now, but that feature detection would
> > > actually be possible if the plugin's "clobbers" was always a child of
> the
> > > "platform" in plugin.xml.
> > >
> > > Right now, most plugins have their clobbers global to all platforms,
> > > supported or not. If the clobbers is a child of the platform, then the
> > > relevant js function/object would be undefined on an unsupported
> > platform.
> > >
> > > This practice would also help in a situation where you might want
> > different
> > > plugins for different platforms, but exposing similar functionality on
> > one
> > > clobbered function/object (eg: the popular barcode scanner plugin + the
> > > blackberry barcode scanner plugin).
> > >
> > > Unfortunately, most plugins don't do this, even though it is possible.
> > > The natural way to determine whether some functionality is available is
> > to
> > > use the "feature detection" pattern. That is, if you want to call some
> > > function normally found at "myobj.myfunc", you write code like this:
> > >
> > > If (myobj && (typeof myobj.myfunc === 'function')) ...
> > >
> > > For this to work you must take care to remove plugins that don't
> support
> > > your platform before you build for that platform. For example, before
> you
> > > build for firefoxos, you must remove the barcodescanner plugin (and
> then
> > > add it back when you build for supported platforms). Granted, this is
> > > awkward, but I think it's worse to read the package.json file.
> > >
> > > Really the CLI should make the feature detection pattern work without
> > > having to exclude plugins on unsupported platforms. That is, if a
> plugin
> > > doesn't support a platform, then it should contribute nothing when you
> > > build for that platform.
> > >
> > > Julian
> > >
> > > -----Original Message-----
> > > From: Axel Nennker [mailto:ignisvulpis@gmail.com]
> > > Sent: Tuesday, February 10, 2015 11:48 AM
> > > To: dev
> > > Subject: Re: Does this plugin support the current platform?
> > >
> > > And then the app has to load that package.json ?
> > > On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:
> > >
> > > > Plugin.xml has a platforms tag for what platforms it supports. That
> > > > info gets uploaded to the Cordova plugins registry when publishing.
> > > >
> > > > Soon this info will be available in package.json file each plugin
> has.
> > > > On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com>
> wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > is there a way how an app can determine whether a plugin supports
> > > > > the current platform?
> > > > >
> > > > > E.g.: the barcodescanner plugin is not supporting firefoxos How
> > > > > could an app know that which out hardcoding this into the app?
> > > > >
> > > > > If there is a standard way in Cordova then this is a userland
> > question.
> > > > > If not then this is a feature request to add this info to e.g.
> > > > > cordova/plugin_list exports.metadata ?!
> > > > >
> > > > > -Axel
> > > > >
> > > >
> > >
> >
>

Re: Does this plugin support the current platform?

Posted by Steven Gill <st...@gmail.com>.
Sounds like a smart change.
On Feb 10, 2015 2:10 PM, "tommy-carlos williams" <to...@devgeeks.org> wrote:

> Nice
>
> +1
>
> One change in Cordova is a lot bette than expecting all plugins to change
> ;)
>
>
> --
> tommy-carlos williams
>
> On 11 February 2015 at 07:54:17, Andrew Grieve (agrieve@chromium.org)
> wrote:
>
> Strawman:
>
> If plugin.xml has *any* <platform>s, then only apply global tags to those
> platforms.
> If plugin.xml has *no* <platform>s, then apply global tags to all
> platforms.
>
> On Tue, Feb 10, 2015 at 2:18 PM, Tommy Williams <to...@devgeeks.org>
> wrote:
>
> > This won't actually help right now, but that feature detection would
> > actually be possible if the plugin's "clobbers" was always a child of the
> > "platform" in plugin.xml.
> >
> > Right now, most plugins have their clobbers global to all platforms,
> > supported or not. If the clobbers is a child of the platform, then the
> > relevant js function/object would be undefined on an unsupported
> platform.
> >
> > This practice would also help in a situation where you might want
> different
> > plugins for different platforms, but exposing similar functionality on
> one
> > clobbered function/object (eg: the popular barcode scanner plugin + the
> > blackberry barcode scanner plugin).
> >
> > Unfortunately, most plugins don't do this, even though it is possible.
> > The natural way to determine whether some functionality is available is
> to
> > use the "feature detection" pattern. That is, if you want to call some
> > function normally found at "myobj.myfunc", you write code like this:
> >
> > If (myobj && (typeof myobj.myfunc === 'function')) ...
> >
> > For this to work you must take care to remove plugins that don't support
> > your platform before you build for that platform. For example, before you
> > build for firefoxos, you must remove the barcodescanner plugin (and then
> > add it back when you build for supported platforms). Granted, this is
> > awkward, but I think it's worse to read the package.json file.
> >
> > Really the CLI should make the feature detection pattern work without
> > having to exclude plugins on unsupported platforms. That is, if a plugin
> > doesn't support a platform, then it should contribute nothing when you
> > build for that platform.
> >
> > Julian
> >
> > -----Original Message-----
> > From: Axel Nennker [mailto:ignisvulpis@gmail.com]
> > Sent: Tuesday, February 10, 2015 11:48 AM
> > To: dev
> > Subject: Re: Does this plugin support the current platform?
> >
> > And then the app has to load that package.json ?
> > On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:
> >
> > > Plugin.xml has a platforms tag for what platforms it supports. That
> > > info gets uploaded to the Cordova plugins registry when publishing.
> > >
> > > Soon this info will be available in package.json file each plugin has.
> > > On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:
> > >
> > > > Hi,
> > > >
> > > > is there a way how an app can determine whether a plugin supports
> > > > the current platform?
> > > >
> > > > E.g.: the barcodescanner plugin is not supporting firefoxos How
> > > > could an app know that which out hardcoding this into the app?
> > > >
> > > > If there is a standard way in Cordova then this is a userland
> question.
> > > > If not then this is a feature request to add this info to e.g.
> > > > cordova/plugin_list exports.metadata ?!
> > > >
> > > > -Axel
> > > >
> > >
> >
>

Re: Does this plugin support the current platform?

Posted by tommy-carlos williams <to...@devgeeks.org>.
Nice

+1

One change in Cordova is a lot bette than expecting all plugins to change ;)


-- 
tommy-carlos williams

On 11 February 2015 at 07:54:17, Andrew Grieve (agrieve@chromium.org) wrote:

Strawman:  

If plugin.xml has *any* <platform>s, then only apply global tags to those  
platforms.  
If plugin.xml has *no* <platform>s, then apply global tags to all platforms.  

On Tue, Feb 10, 2015 at 2:18 PM, Tommy Williams <to...@devgeeks.org> wrote:  

> This won't actually help right now, but that feature detection would  
> actually be possible if the plugin's "clobbers" was always a child of the  
> "platform" in plugin.xml.  
>  
> Right now, most plugins have their clobbers global to all platforms,  
> supported or not. If the clobbers is a child of the platform, then the  
> relevant js function/object would be undefined on an unsupported platform.  
>  
> This practice would also help in a situation where you might want different  
> plugins for different platforms, but exposing similar functionality on one  
> clobbered function/object (eg: the popular barcode scanner plugin + the  
> blackberry barcode scanner plugin).  
>  
> Unfortunately, most plugins don't do this, even though it is possible.  
> The natural way to determine whether some functionality is available is to  
> use the "feature detection" pattern. That is, if you want to call some  
> function normally found at "myobj.myfunc", you write code like this:  
>  
> If (myobj && (typeof myobj.myfunc === 'function')) ...  
>  
> For this to work you must take care to remove plugins that don't support  
> your platform before you build for that platform. For example, before you  
> build for firefoxos, you must remove the barcodescanner plugin (and then  
> add it back when you build for supported platforms). Granted, this is  
> awkward, but I think it's worse to read the package.json file.  
>  
> Really the CLI should make the feature detection pattern work without  
> having to exclude plugins on unsupported platforms. That is, if a plugin  
> doesn't support a platform, then it should contribute nothing when you  
> build for that platform.  
>  
> Julian  
>  
> -----Original Message-----  
> From: Axel Nennker [mailto:ignisvulpis@gmail.com]  
> Sent: Tuesday, February 10, 2015 11:48 AM  
> To: dev  
> Subject: Re: Does this plugin support the current platform?  
>  
> And then the app has to load that package.json ?  
> On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:  
>  
> > Plugin.xml has a platforms tag for what platforms it supports. That  
> > info gets uploaded to the Cordova plugins registry when publishing.  
> >  
> > Soon this info will be available in package.json file each plugin has.  
> > On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:  
> >  
> > > Hi,  
> > >  
> > > is there a way how an app can determine whether a plugin supports  
> > > the current platform?  
> > >  
> > > E.g.: the barcodescanner plugin is not supporting firefoxos How  
> > > could an app know that which out hardcoding this into the app?  
> > >  
> > > If there is a standard way in Cordova then this is a userland question.  
> > > If not then this is a feature request to add this info to e.g.  
> > > cordova/plugin_list exports.metadata ?!  
> > >  
> > > -Axel  
> > >  
> >  
>  

Re: Does this plugin support the current platform?

Posted by Andrew Grieve <ag...@chromium.org>.
Strawman:

If plugin.xml has *any* <platform>s, then only apply global tags to those
platforms.
If plugin.xml has *no* <platform>s, then apply global tags to all platforms.

On Tue, Feb 10, 2015 at 2:18 PM, Tommy Williams <to...@devgeeks.org> wrote:

> This won't actually help right now, but that feature detection would
> actually be possible if the plugin's "clobbers" was always a child of the
> "platform" in plugin.xml.
>
> Right now, most plugins have their clobbers global to all platforms,
> supported or not. If the clobbers is a child of the platform, then the
> relevant js function/object would be undefined on an unsupported platform.
>
> This practice would also help in a situation where you might want different
> plugins for different platforms, but exposing similar functionality on one
> clobbered function/object (eg: the popular barcode scanner plugin + the
> blackberry barcode scanner plugin).
>
> Unfortunately, most plugins don't do this, even though it is possible.
> The natural way to determine whether some functionality is available is to
> use the "feature detection" pattern.  That is, if you want to call some
> function normally found at "myobj.myfunc", you write code like this:
>
> If (myobj && (typeof myobj.myfunc === 'function')) ...
>
> For this to work you must take care to remove plugins that don't support
> your platform before you build for that platform.  For example, before you
> build for firefoxos, you must remove the barcodescanner plugin (and then
> add it back when you build for supported platforms).  Granted, this is
> awkward, but I think it's worse to read the package.json file.
>
> Really the CLI should make the feature detection pattern work without
> having to exclude plugins on unsupported platforms.  That is, if a plugin
> doesn't support a platform, then it should contribute nothing when you
> build for that platform.
>
>     Julian
>
> -----Original Message-----
> From: Axel Nennker [mailto:ignisvulpis@gmail.com]
> Sent: Tuesday, February 10, 2015 11:48 AM
> To: dev
> Subject: Re: Does this plugin support the current platform?
>
> And then the app has to load that package.json ?
> On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:
>
> > Plugin.xml has a platforms tag for what platforms it supports. That
> > info gets uploaded to the Cordova plugins registry when publishing.
> >
> > Soon this info will be available in package.json file each plugin has.
> > On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > is there a way how an app can determine whether a plugin supports
> > > the current  platform?
> > >
> > > E.g.: the barcodescanner plugin is not supporting firefoxos How
> > > could an app know that which out hardcoding this into the app?
> > >
> > > If there is a standard way in Cordova then this is a userland question.
> > > If not then this is a feature request to add this info to e.g.
> > > cordova/plugin_list exports.metadata ?!
> > >
> > > -Axel
> > >
> >
>

RE: Does this plugin support the current platform?

Posted by Tommy Williams <to...@devgeeks.org>.
This won't actually help right now, but that feature detection would
actually be possible if the plugin's "clobbers" was always a child of the
"platform" in plugin.xml.

Right now, most plugins have their clobbers global to all platforms,
supported or not. If the clobbers is a child of the platform, then the
relevant js function/object would be undefined on an unsupported platform.

This practice would also help in a situation where you might want different
plugins for different platforms, but exposing similar functionality on one
clobbered function/object (eg: the popular barcode scanner plugin + the
blackberry barcode scanner plugin).

Unfortunately, most plugins don't do this, even though it is possible.
The natural way to determine whether some functionality is available is to
use the "feature detection" pattern.  That is, if you want to call some
function normally found at "myobj.myfunc", you write code like this:

If (myobj && (typeof myobj.myfunc === 'function')) ...

For this to work you must take care to remove plugins that don't support
your platform before you build for that platform.  For example, before you
build for firefoxos, you must remove the barcodescanner plugin (and then
add it back when you build for supported platforms).  Granted, this is
awkward, but I think it's worse to read the package.json file.

Really the CLI should make the feature detection pattern work without
having to exclude plugins on unsupported platforms.  That is, if a plugin
doesn't support a platform, then it should contribute nothing when you
build for that platform.

    Julian

-----Original Message-----
From: Axel Nennker [mailto:ignisvulpis@gmail.com]
Sent: Tuesday, February 10, 2015 11:48 AM
To: dev
Subject: Re: Does this plugin support the current platform?

And then the app has to load that package.json ?
On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:

> Plugin.xml has a platforms tag for what platforms it supports. That
> info gets uploaded to the Cordova plugins registry when publishing.
>
> Soon this info will be available in package.json file each plugin has.
> On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:
>
> > Hi,
> >
> > is there a way how an app can determine whether a plugin supports
> > the current  platform?
> >
> > E.g.: the barcodescanner plugin is not supporting firefoxos How
> > could an app know that which out hardcoding this into the app?
> >
> > If there is a standard way in Cordova then this is a userland question.
> > If not then this is a feature request to add this info to e.g.
> > cordova/plugin_list exports.metadata ?!
> >
> > -Axel
> >
>

RE: Does this plugin support the current platform?

Posted by "Horn, Julian C" <ju...@intel.com>.
The natural way to determine whether some functionality is available is to use the "feature detection" pattern.  That is, if you want to call some function normally found at "myobj.myfunc", you write code like this:

If (myobj && (typeof myobj.myfunc === 'function')) ...

For this to work you must take care to remove plugins that don't support your platform before you build for that platform.  For example, before you build for firefoxos, you must remove the barcodescanner plugin (and then add it back when you build for supported platforms).  Granted, this is awkward, but I think it's worse to read the package.json file.

Really the CLI should make the feature detection pattern work without having to exclude plugins on unsupported platforms.  That is, if a plugin doesn't support a platform, then it should contribute nothing when you build for that platform.

    Julian

-----Original Message-----
From: Axel Nennker [mailto:ignisvulpis@gmail.com] 
Sent: Tuesday, February 10, 2015 11:48 AM
To: dev
Subject: Re: Does this plugin support the current platform?

And then the app has to load that package.json ?
On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:

> Plugin.xml has a platforms tag for what platforms it supports. That 
> info gets uploaded to the Cordova plugins registry when publishing.
>
> Soon this info will be available in package.json file each plugin has.
> On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:
>
> > Hi,
> >
> > is there a way how an app can determine whether a plugin supports 
> > the current  platform?
> >
> > E.g.: the barcodescanner plugin is not supporting firefoxos How 
> > could an app know that which out hardcoding this into the app?
> >
> > If there is a standard way in Cordova then this is a userland question.
> > If not then this is a feature request to add this info to e.g.
> > cordova/plugin_list exports.metadata ?!
> >
> > -Axel
> >
>

Re: Does this plugin support the current platform?

Posted by Axel Nennker <ig...@gmail.com>.
And then the app has to load that package.json ?
On Feb 10, 2015 5:28 PM, "Steven Gill" <st...@gmail.com> wrote:

> Plugin.xml has a platforms tag for what platforms it supports. That info
> gets uploaded to the Cordova plugins registry when publishing.
>
> Soon this info will be available in package.json file each plugin has.
> On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:
>
> > Hi,
> >
> > is there a way how an app can determine whether a plugin supports the
> > current  platform?
> >
> > E.g.: the barcodescanner plugin is not supporting firefoxos
> > How could an app know that which out hardcoding this into the app?
> >
> > If there is a standard way in Cordova then this is a userland question.
> > If not then this is a feature request to add this info to e.g.
> > cordova/plugin_list exports.metadata ?!
> >
> > -Axel
> >
>

Re: Does this plugin support the current platform?

Posted by Steven Gill <st...@gmail.com>.
Plugin.xml has a platforms tag for what platforms it supports. That info
gets uploaded to the Cordova plugins registry when publishing.

Soon this info will be available in package.json file each plugin has.
On Feb 10, 2015 7:25 AM, "Axel Nennker" <ig...@gmail.com> wrote:

> Hi,
>
> is there a way how an app can determine whether a plugin supports the
> current  platform?
>
> E.g.: the barcodescanner plugin is not supporting firefoxos
> How could an app know that which out hardcoding this into the app?
>
> If there is a standard way in Cordova then this is a userland question.
> If not then this is a feature request to add this info to e.g.
> cordova/plugin_list exports.metadata ?!
>
> -Axel
>