Sunday, March 19, 2017

What is cordova plugin? & How to add plugin in cordova project.

What is cordova plugin?
  1. Plugin is one of the most important thing in cordova mobile apps.
  2.  Plugin is a package of injected code that allows the cordova webview within which the app renders to communicate with the native platform on which its runs.
  3. Plugin provide access to device and platform functionality that is ordinarily not available to web apps.
  4. Plugin comprise a  single JavaScript interface along with corresponding native code libraries for each supported platform. In essence this hides the various native code implementation behind a common JavaScript interface. 
  5. Main cordova API features are implemented as plugins. through these plugins you can access all native functionality in your cordova mobile app or you can create your own plugin to fully your requirement in app. 
  6. In cordova there are many cordova plugins are available for use or you can create your own plugin and published it to cordova open source community. So any one can use it.
How to add plugin in cordova project
  1. Adding plugin to cordova project is very simple just required to run some following command in CLI.
  2. First you have entered to your cordova project that you already crearted like i have already created sampleX project previously.
  3. So now i am adding cordova splash screen plugin using CLI
  4. So open your cmd and select your project path - C:\Users\sushant>cd sampleX
  5. After entered your project folder run below cmd -
    cordova plugin add cordova-plugin-splashscreen
  6.  Plugin will download from srouce. one download completed it will added to our cordova project Plugin directory . assets/www  folder is our working directory where you will add all your code into this directory. you can also see that i am added plugins which are come under plugin folder where you can see the splash screen folder.
  7. So now build the project and run it. when the mobile app start first time you will see a splash screen with cordova default image on it.
  8.  You can change your splash screen with your own app splash screen. So Goto res folder where you will see many folders in that drawable-XXXX-XXXX folders have splash screen images which have specific dimension as per device type. So just replace your splash screen with default splash screen.

No comments:

Post a Comment

Cordova Push Notification Using Firebase & Onesignal Plugin

What is Push Notification Push notification is one of the best way to send messages to app user and its simplest way to reach to the a...