I am trying to get cordova-plugin-camera
working on my Ionic app. I installed it using cordova plugin add cordova-plugin-camera --save
and then npm i --save @ionic-native/camera
. The node_modules folder for the package is populated and the plugin exists in all my plugins folders, I have also verified that cordova plugin list
shows the plugin. I’m using the following code to attempt to start the camera but it is not working:
import { Component } from "@angular/core";
import { Camera, CameraOptions } from "@ionic-native/camera";
@Component({
selector: "page-camera",
templateUrl: "camera.html"
})
export class CameraPage {
public base64Image: string;
constructor(public camera: Camera) {}
takePicture() {
this.camera
.getPicture({
destinationType: this.camera.DestinationType.DATA_URL,
targetWidth: 1000,
targetHeight: 1000
})
.then(
imageData => {
// imageData is a base64 encoded string
this.base64Image = "data:image/jpeg;base64," + imageData;
},
err => {
console.log(err);
}
);
}
}
When running this and clicking the button that calls takePicture()
I get no camera launched and no console errors but inside of safari I get the following error:
2018-12-13 11:31:24.183490-0500 MyApp[3844:312133] ERROR: Plugin 'Camera' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2018-12-13 11:31:24.183546-0500 MyApp[3844:312133] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["Camera1764610053","Camera","takePicture",[50,0,1,1000,1000,0,0,false,false,false,null,0]]