How to User Cordova Camera Plugin
Cordova Camera Plugin provides access to the device's (IOS/ANDROID) native camera application. Is used for getting the picture from camera or existing gallery in cordova applications. After taking a picture we can use FILE_URI or DATA_URI for displaying picture to user or we can also store images into remote servers
Add Plagin
cordova plugin add cordova-plugin-camera
Accessing Camera
Take a photo and retrieve it as a base64-encoded image:
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.DATA_URL
});
function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
