All plugins undefined in ionic2

hi , i have installed some plugins in my fresh ionic2 app but none of them are working
camera, toast, push result in error error cannot read property of undefined

this is what i’m doing for one of them (camera)

installation

$ ionic plugin add cordova-plugin-camera

code
`getpic(){
Camera.getPicture(onSuccess, onFail, {
quality: 50, destinationType: Camera.DestinationType.FILE_URI
});
function onSuccess(imageData){
var image = document.getElementById(‘myImage’);
image.src = imageURI
}

function onFail(message){
alert(“Failed because:” + message)

}
}

`
i also import Camera from ionic

this is what i get

even if i use navigator.camera.getPicture it result the same , and for all plugins , they are undefined
someone can help me with this?

Are you trying to run this through the browser? Plugins only work when running on a device.

i’m running this on device too, none of them are working

I don’t know if this will help your situation but I had a plug-in problem the other day which would only fix itself if I used the cordova plugin rather than the ionic plugin command. See here.

1 Like

Yes , it works , many thanks

Doesn’t work for me… Trying to add toasts to my existing project.
Trying to test on my Nexus 5 device using ionic run android, but I could see that window.plugins is undefined :frowning:
Same plugin works fine if installed in fresh typescript project. I Just cant make it work on my existing ES6 project. Trying to remove using ionic plugin remove cordova-plugin-x-toast and then reinstall by cordova plugin add cordova-plugin-x-toast but no luck…
Maybe anyone knows the way to debug this?
BTW Using another plugin for scanning barcodes and it works just fine…

this.platform.ready().then(() => {
            //console.log(window.plugins);
           if (!!cordova) console.log('DEBUG || ' + JSON.stringify(cordova.plugins));
           if (!!window.plugins)  console.log('DEBUG || ' + JSON.stringify(window.plugins));
            window.plugins.toast.show(message, "short", position);
        });
1 Like

mobile

Same here, I do not understand, why window[‘plugins’].OrtcPushPlugin as undefined.

2018 and still the same problem