Can;t get cordova plugins working in ionic 3


#1

HI Guys.

Pretty new to ionic switching from phonegap and f7. Absolutely love it however a few teething problems.

I’ve looked on the forums already to find a solution and none have worked.

I can’t seem to get non ionic native cordova plugins working in ionic.

My repro steps are:

ionic start projectname tabs
cd projectname
ionic cordova plugin add pluginname

Then just to test i went into the home.ts component to try and run a plugin function on device ready.

I’ve tried calling the plugin via:

window.plugins.pluginname.method();
window.pluginname.method();
(<any>window).plugins.pluginname.method();
cordova.plugins.pluginname.method();

I’ve even tried the following declares above the component

declare let cordova: any;
declare var window;

Every time i get an error saying undefined is not an object, and when i try to console log dump the plugin itself its coming up as null. Tried in a browser but also in devapp on IOS11.

My ionic info is below.

cli packages: (C:\Users\Robert.Lane\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.10
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v9.5.0
    npm  : 5.6.0
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro


Really pulling my hair out on this one, can someone please adivse. Or, if you have an example project with a a non standard cordova plugin working that would be amazing.

Thank you!