Cordova plugins: how to install, how they work, examples
What are cordova plugins?
Cordova plugins are in simple words a layer on top of the respective native platform.
Plugins provide an interface between to access the native platform.
How can Cordova plugins be useful?
Cordova Plugins provide a common interface to interact with the native code.
Each plugin has an intermediary JavaScript file that provides access to platform specific features.
Installing Cordova Plugin
cordova plugin add <plugin-name>
Example: cordova plugin add cordova-plugin-camera
The plugin should be installed in the root directory of the project.
Note:
Before adding the plugin replace the platform specific www folder content with the outer www folder in the root directory. This is because on adding a plugin the contents of the outer www folder are replaced with the platform specific www folder.
Note:
When you add a new platform and if you have any installed plugins on your project is not necessary to install the existing plugins. Cordova automatically will add the installed plugins for the new platform.
Most Popular Plugins
-
cordova-plugin-battery-status - used for monitoring device’s battery status.
-
cordova-plugin-camera - provides an API for taking pictures and for choosing images from the system’s image library.
-
cordova-plugin-contacts - provides access to the device contacts database.
-
cordova-plugin-device - describes the device’s hardware and software.
-
cordova-plugin-device-motion - access to the device’s accelerometer.
-
cordova-plugin-file - implements a File API allowing read/write access to files residing on the device.
-
cordova-plugin-geolocation - provides information about the device’s location, such as latitude and longitude.
-
cordova-plugin-globalization - obtains information and performs operations specific to the user’s locale, language, and timezone.
-
cordova-plugin-inappbrowser - show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app.
-
cordova-plugin-network-information - provides information about the device’s cellular and wifi connection, and whether the device has an internet connection.
-
cordova-plugin-vibration - provides a way to vibrate the device.
-
cordova-plugin-statusbar - provides some functions to customize the iOS and Android StatusBar.
-
cordova-plugin-whitelist - implements a whitelist policy for navigating the application webview on Cordova 4.0. Recommended plugin!
For cordova specific plugins follow below link https://cordova.apache.org/plugins/