Cordova is an open source software package that is commonly used to wrap a web-based mobile application inside of a native wrapper, which allows the application to access native device functionality, and to be submitted to native app stores.
However, there is often confusion between what Cordova is, what a plugin is, and how you can use them in an Ionic 2 application. In this video tutorial, I walk through these basic concepts right from the beginning in order to give you the “full picture” of how it all works.
Cordova plugins provide a little bridge, so that we can make our browser based application communicate with cordova package, which can then communicate with the native apis to get what we want and tell us the information we need. So, the flow of information is,
- browser tells cordova what is needed
- cordova then communicates with the device
- device gives the needed information to the cordova package
- cordova package delivers the information to the browser which our application then access
Cordova doesn’t need any framework to work. We can just package any web app with cordova and cordova plugins. But it is very difficult to do all the things like maintaining UIs, implementing basic functionalities. That is why we use frameworks like Ionic, Angular Mobile and so on. These frameworks provide us with basic functionalities, use interfaces letting developers focus on their application functionality.
- Ionic applications or any other web applications can be packaged with Cordova. Cordova creates a native wrapper for our browser based application, which allows it submit to app stores as a native app
- Cordova plugins creates an interface for our browser based code to access native device functionalities
- Cordova plugins can be used the same way in any Cordova application, regardless of the framework (e.g. Ionic) that is used
- The Ionic Native service is not required to use Cordova plugins, but it does makes Cordova plugins easier to use in Ionic applications
- We must make sure to install any Cordova plugins that we want to use through the command line, using:
ionic plugin add the-plugin-name
Originally from Joshmorony