Cordova is used to making cross-platform mobile applications and provides a wide range of plugins for better functionality of the app which is easy to embed.
We are installing the Cordova command-line tool. If not already installed follow the steps given below :
- Download Node.js and install it from here.
- Using npm utility(Node.js) to install Cordova module
Installation on Linux / macOS
Prefixing the sudo command to the npm command might be needed to install the utility
$ sudo npm install -g cordova
Installation on Windows
The -g flag tells the npm utility to install Cordova globally
C:\>npm install -g cordova
Run Cordova in the command line to check if properly installed if installed it should print help text.
Cordova’s Application Architecture
Cordova has a high-level design the diagram shown below depicts its architecture
Web View: This is the user interface of the Cordova application. The applications used are integrated with the web view and the native components(for hybrid apps).
Plugins are one of the best features in Cordova. Integrating plugins adds apps functionality and attractiveness. Cordova maintains a set of plugins called Core Plugins which provides application capabilities like Camera, Battery, File transfer etc. In addition to the core plugins, there are several third-party plugins that provide additional bindings to features. Cordova does not provide any mv framework or widgets. Plugins are necessary for functionality like communication between Cordova and custom native components. Plugins can be searched using the npm command or searched at the link given below
Basically there are two development paths in Cordova each with its own advantages :
- Cross-Platform Workflow: This workflow is centered around the command-line interface(CLI) and mostly used when a developer wants the application to run on different platforms. This workflow has very little need for platform-specific developments. Here the CLI copies assets of different platforms into sub-directories for each of the platforms and has a common interface to apply plugins.
- Platform-centered Workflow: This workflow is centered around lower-level shell scripts for a specif platform and is used when a developer is focused on building an application on a single platform and wants to modify it at a lower level like adding native components to the web-based components. This workflow does not have any high-level tools. If a user wants to modify the application with SDK the Platform-centered workflow is used
- Command Line Interface: Used for installing plugins and writing commands to build a Cordova application
- Cordova Plugins: Many APIs can be used in Cordova to add functionality to a Cordova application
- Cordova Core Components: A set of components used to build the application
Advantages of using Cordova
- Easy to use and does not require a lot of time to make an application with Cordova.
- There is no need to learn a specific development programming language to develop an application.
- Cordova follows a plugin architecture, many plugins to work with which can be added and modified. We can enable and disable plugins as per our priorities.
- Is a platform for developing an application that can be used in different platforms — Ubuntu, Windows, Blackberry, etc.
- Not all plugins are compatible with every platform.
- Hybrid apps are slower than native apps.
- Not optimum for making an application that requires a large set of data.