Cordova plugins, how do they work? ;)


#1

Playing around with my first Ionic2 app (first Ionic or Cordova anything)… I have a fairly simple app set up and am pulling data from an API. Works great… but I’ve tried to install and use two different Cordova plugins, and I’m unable to get them to work by following the docs.

Take this doc as an example. From the looks of it, all you should have to do is run “cordova plugin add cordova-plugin-network-information”. I even tried “cordova prepare” and “cordova build ios” after it.

When I try to import the previously mentioned plugin (after installing) with “import { Network, Connection } from ‘ionic-native’;”, I get “[ts] Module ‘…/ionic-native/dist/index’ has no exported member…” for both Network and Connection.

I feel like there’s a step or two here that the docs assume I already know. :slight_smile:

[Edit]
Something else I should mention as I’m Googling… running the “cordova plugin add…” command didn’t add the plugin to my config.xml file. Is is supposed to?


#2

Have you installed ionic-native?

npm install ionic-native --save


#3

I have the same problem than @Kizmar and I have installed ionic-native via npm.
I try to import Network and Connection like that : import { Network, Connection } from 'ionic-native'; but they are not exported by ionic-native. Why ?

If we follow the documentation of the class Network, Network and Connection should be exported.

Please I need help about ionic-native :confused:


#4

I hadn’t tried using the Network plugin before and now that I have I’m getting the same issue. I have the latest version of Ionic-native, 1.1.0 but there is no Network plugin though it is in the master branch on Github.

Curious as to why I’m not getting it, i’ve deleted my ionic-native node directory and reinstalled with the same results.


#5

And even with the Camera class I haven’t the constants we use in options:

// Camera constants, defined in Camera plugin DestinationType: { DATA_URL: number; FILE_URI: number; NATIVE_URI: number } Direction: { BACK: number; FRONT: number; } EncodingType ...


#6

npm package isn’t updated. You could use sources or just wait.


#7

Good to know, thanks.