How to use cordova plugins with Ionic 2?



I tried to use PhoneRTC plugin ( inside my Ionic 2 application.

In Component I tried:

//noinspection TypeScriptUnresolvedVariable var session = new cordova.plugins.phonertc.Session(config);

I can’t see any error but application is not loading at all…


Well if you’re using TypeScript you would need to add something like:

declare var cordova: any;

This will tell TypeScript not to worry about that strange variable that popped out of no where.

Also you should have a look at ionic-native, it’s a library that provides wrappers for most of the plugins you will need. These wrappers return back Promises and Observables instead of using callback functions. This will give you many benefits including change detection triggering in Angular 2.



I did use it in the way ihadeed said.

declare var cordova: any;
var session = new cordova.plugins.phonertc.Session(config);

but now I am now getting error:

TypeError: Cannot read property ‘Session’ of undefined.
Please help me figure out what more do I do to make a session in ionic 2.


did you find the answer ?