5

I have been trying to use the ionic-native plugins provided by Ionic 3. When I read the install instructions, there are always 2 command lines instead of one.

ionic cordova plugin add cordova-plugin-camera
npm install --save @ionic-native/camera

If my memory serves me right, only a single command similar to ionic plugin add somepluginhere will get the job done in the old days.

What are the differences here?

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
S.C.
  • 900
  • 1
  • 13
  • 39

1 Answers1

6

The difference is they are different packages.

ionic cordova plugin add

This command will download the cordova plugin - in this case, camera and set the config.xml , package.json, save in plugins folder and set it for each of your platforms. Ionic leverages the cordova CLI to do this.

ionic-native

Ionic Native is simply a wrapper to the corresponding plugin.

npm install --save @ionic-native/camera

It installs the package @ionic-native/camera to your node-modules folder and sets that in package.json and nothing more.
This wrapper allows you to inject the corresponding cordova plugin as an Angular provider wherever you need instead of trying to declare the global variable and other workarounds.

Community
  • 1
  • 1
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103