Tag Archives: plug-ins

Adding plugins to Ionic 2

In the current app I am building I need to use the network information plugin so to add it I ran the command:

ionic plugin add cordova-plugin-network-information

In my Ionic 1 apps I always used ionic plugin add to add my plugins as the plugin is then automatically added to the package.json file (which I assumed was good).

Anyway, after adding the plug-in (and without adding any code to actually use it) I built the app and tested it on a device. The app crashed on loading (no errors in the log – just crashed on startup). I removed the plugin and added it again and re-tested. Same thing happened.

Then I tried removing the plugin and adding it back again but this time using:

cordova plugin add cordova-plugin-network-information

This time when I built the app, it worked.  I thought the only difference between the ionic plugin command and the cordova plugin command was the entry in package.json but presumably there are other differences?   Changing to the cordova command also appears to have helped someone else so its not just me.

 


I’m a mobile applications developer based in the UK, concentrating primarily on hybrid application development with Ionic and Ionic 2 but also with native development skills. Please visit www.crossplatformsolutions.co.uk for more information about me and how I may be able to help you with mobile application development, particularly with Ionic 2 but also with other mobile frameworks and technologies.  Thanks for visiting.