Ionic2 Cordova Plugins not working


#1

Hi All,

I am creating a new Ionic2 app.


My issue is I am trying to make use of the cordova-plugin-camera plugin, but can’t access the Camera object. If anyone knows what I am doing wrong, I would appreciate some help.


Error from CLI after:

ionic run android --livereload --lc

I have some Cordova plugins installed, e.g.

cordova plugin add cordova-plugin-camera --save --global

I have also installed typings:

npm install -g typings

When I try the following, I get another error:

typings install cordova --save --global

My sourcecode:


#2

SOLVED: added the following, now it works.

declare var navigator: any;


#3

Instead using the raw cordova plugin, you should use ionic-native

Not only does it provide the proper type information and autocompletion, but it handles any errors that cordova and angular2 can create. Most of which come from cordova’s callbacks and angular using promises and observables.


#4

Thank you mhartington, will do