2 Quick Tips When Adding PhoneGap/Cordova Plugins

July 15, 2014By 0 Comments

Here are a few quick tips when adding plugins in case you weren’t aware of them previously:

  1. Useful command line shortcuts when adding a plugin:

    Add a specific version of a plugin using the @ syntax

    $ phonegap plugin add org.apache.cordova.camera@0.2.9
    $ cordova plugin add org.apache.cordova.camera@0.2.9

    Add multiple plugins batch style

    $ phonegap plugin add org.apache.cordova.file org.apache.cordova.device
    $ cordova plugin add org.apache.cordova.file org.apache.cordova.device

  2. Use the docs from the plugin add location

    This may be fairly obvious though I still wanted to point it out. To avoid any headaches with a plugin version mismatch between installed plugin code and docs, be sure to use the docs from where you added the plugin instead of assuming the latest Cordova/PhoneGap documentation links.

    If you add via Plugin Registry such as:
    $ phonegap plugin add org.apache.cordova.contacts
    $ cordova plugin add org.apache.cordova.contacts

    If you add via GitHub location such as:
    $ phonegap plugin add https://github.com/apache/cordova-plugin-contacts
    $ cordova plugin add https://github.com/apache/cordova-plugin-contacts

    This applies for each of the core API plugins.


    Currently the Plugin API documentation points to the GitHub location which contains the very latest code/updates. These code updates get released to the Plugin Registry in a timely fashion, but there can be a time when a mismatch could occur, like when you’ve installed a plugin via the Plugin Registry but are referencing the GitHub docs where a new feature was documented but not in the version you actually installed. (Thanks to Ray Camden for noticing the Contacts plugin mismatch recently).

Filed in: CordovaiOSMobile DevelopmentPhoneGap

About the Author ()

Leave a Reply