Cordova Discovery Tour Series (ii)

Source: Internet
Author: User
Tags git clone repository

There is a very important concept in Cordova: plugins .

The plug-in provides an interface to access the Cordova core API.

Plug-ins are additional code that provides the interface to access native components. In general, you will need to add some plugins to start Cordova device-level features.

Plugins are provided by the official and community, can be found on Plugins.cordova.io, and of course can be searched on the command line for plugins.

Since 3.0, Cordova has all of the device's APIs as plug-ins and is set to not start by default.

So, how do you add plugins? Two different ways.

The first is to use the CLI command line.

The second is to use lower-level command-line Plugman.

The difference between the two is that Plugman can only add one platform plugin at a time, and the CLI command line adds plug-ins for all platforms . So if you're only working on a single platform, it's more reasonable to use Plugman.

To add a plug-in using CLI command line:

1. Add Plugins

tr>
 1  
cordova plugin add org.apache.cordova.camera   

2. Remove Plugins

tr>
 1  
cordova plugin rm org.apache.cordova.camera   

3. View currently existing plugins

tr>
 1  
cordova plugin ls   

4. Search for plugins by keyword

tr>
 1  
cordova plugin search bar code   

5. Many plugins are available in the community, but if it is not registered to Registry.cordova.io, you can add it through the warehouse address

tr>
 1  
cordova plugin add Https://github.com/apache/cordova-plugin-console.git 
To add a plugin using Plugman:

First you need to install Plugman

tr>
 1  
npm install-g plugman   

1. Add a plugin

1
plugman--platform <ios|amazon-fireos|android|blackberry10|wp7|wp8>--project < directory>--plugin <name|url|path> [--plugins _dir <directory>]  [--www <directory>]  [--variable <name>=  <value> [-- Variable <name>=  <value> ... ]  

Add a plugin to a Cordova project via the Plugman command line. You must specify at least the platform information, Cordova the project location.

Name: The directory names of the plugins. It must be present in the Plugins_dirpath path or registered in the Cordova.

URL: A URL that begins with "/http" or "git://", pointing to a legitimate Git clone repository, which should contain a plugin.xml file, and the contents of the repository can be copied to the Plugins_dir path.

Path: A path to a directory containing a legitimate plug-in (containing a plugin.xml file). The contents of this path can be copied to Plugins_dir. Other parameters:

plugin_dir: The default is to point to/cordova/plugins, or it can be any subdirectory that contains each acquired plug-in.

www: Default to the project's WWW directory, but you can also point to the application Web asserts directory for the Cordova project.

variable: Allows certain variables to be specified at installation time, which is necessary for some plugins to require API key or other user-defined parameters.

Here is the installation command line to add the battery status plug-in

1  
plugman-d--platform android--project Myproject–plugin Org.apache.cordova.battery-status   

The-D or-debug parameter will help you print out internal debugging information to help you track specific information.

2. Delete a plugin

Plugman--uninstall--platform <ios|amazon-fireos|android|blackberry10|wp7|wp8>--project <directory>-- Plugin <id> [--www <directory>] [--plugins_dir <directory>]

Cordova Discovery Tour Series (ii)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.