Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CECA710E68 for ; Tue, 10 Feb 2015 19:19:52 +0000 (UTC) Received: (qmail 84889 invoked by uid 500); 10 Feb 2015 19:19:52 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 84847 invoked by uid 500); 10 Feb 2015 19:19:52 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 84831 invoked by uid 99); 10 Feb 2015 19:19:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Feb 2015 19:19:52 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of tommy@devgeeks.org designates 74.125.82.173 as permitted sender) Received: from [74.125.82.173] (HELO mail-we0-f173.google.com) (74.125.82.173) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Feb 2015 19:19:24 +0000 Received: by mail-we0-f173.google.com with SMTP id w55so24190364wes.4 for ; Tue, 10 Feb 2015 11:18:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=3xbiqAC2vVPxA2SGu1SkYaNx0PtGKrUnMrXvVeezRzY=; b=GDqNBJO4e9O/xy98Qv+mthJBzQIGeb/oHO7ZjzOxNtdq2UN8HEyXvE5MNTT0rHdFMU riuQH8UmXdvZD4K/XQKI60dEe4dRIMWTqJIkNgnb8By832Urgj2Y3mSMtvimUblRPxNP q+Mj4KQgDY3bjcSha9nFaYVyNHWSIxY5itoEpmf1+NMlcILtlL2QgGYEgJQ1IzSTG84d PyZIHpCBS9rwoH5mXhZOF+r0/vGn9Fk9qA2iSGBh7wLqrnxa+TlWrIjFOqk64aCN/pPz 9Z/3tDeDNlR9i1JNS05HEnhwVKxjael7sEDZDwplBbxRk735+6f3VTxqPvm5ju4zS4/P SMJA== X-Gm-Message-State: ALoCoQnfYN2OxIbGjy4Qzecol/Bz8AtSSk+TwbdDQJMIPxOHkAsWqyxFFl3saAzGrks2yraIxxm1 MIME-Version: 1.0 X-Received: by 10.194.2.75 with SMTP id 11mr56140683wjs.78.1423595918338; Tue, 10 Feb 2015 11:18:38 -0800 (PST) Received: by 10.180.74.172 with HTTP; Tue, 10 Feb 2015 11:18:38 -0800 (PST) X-Originating-IP: [120.144.35.78] Received: by 10.180.74.172 with HTTP; Tue, 10 Feb 2015 11:18:38 -0800 (PST) In-Reply-To: References: Date: Wed, 11 Feb 2015 06:18:38 +1100 Message-ID: Subject: RE: Does this plugin support the current platform? From: Tommy Williams To: dev@cordova.apache.org Content-Type: multipart/alternative; boundary=047d7b3a834c0441e0050ec0c1aa X-Virus-Checked: Checked by ClamAV on apache.org --047d7b3a834c0441e0050ec0c1aa Content-Type: text/plain; charset=UTF-8 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" 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" 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 > > > --047d7b3a834c0441e0050ec0c1aa--