How to use Cordova In Ionic Project

Ionic apps are created and developed primarily through the Ionic command line utility (the “CLI”), and use Cordova to build/deploy as a native app. This means we need to install a few utilities to get developing.

With Node and NPM setup, you can install the Cordova CLI like this

npm install -g ionic cordova

Above command will install cordova globally so that you can use it in any Ionic Project.

Now its time to use cordova for your project. Using cordova, you can generate your app icons, splash screen assets just by running a single command

ionic cordova resources

It will add resources folder in the root of your project directory and add sample icon.png and splash.png image. Now you can replace it with your own image.

The source image for icons should ideally be at least 1024×1024px and located at resources/icon.png. The source image for splash screens should ideally be at least 2732×2732px and located at resources/splash.png. If you used ionic start, there should already be default Ionic resources in the resources/ directory, which you can overwrite.

Now you can generate platform specific icons and splash screen using following commands

ionic cordova resources ios
ionic cordova resources android

Once resources are added, you can add platform using following commands

ionic cordova platform add ios
ionic cordova platform add android

Okay, it’s time to build your app and generate necessary apk file using Android Studio and ipa using Xcode. The commands are

ionic cordova build android
ionic cordova build ios

For production release, you should use following commands

ionic cordova build android --prod --release
ionic cordova build ios --prod --release