In my previous article I explained the camera.getPicture method of Camera in Apache Cordova/PhoneGap which is used to get or retrieve the pictures from the camera and we can also take the picture using the camera. The picture is returned either as an URL of the image or a base64 encoded string.

navigator.camera.getPicture( cameraSuccess, cameraError, [ cameraOptions ] );

The same parameter that we used in camera.getPicture can also be used in this second method; these are:

In this article I explain the method camera.cleanup method of camera in PhoneGap/Cordova.

camera.cleanup

This method can be used to clean up the image files that were taken by the camera and stored in a temporary storage location. The camera.getPicture can be used to take the picture and this is used to remove the pictures stored in a temporary location. The only supported platform of this method is iOS.The camera.getPicture is used with camera.sourceType = camera.PictureSourceType.CAMERA and Camera.destinationType = Camera.DestinationType.FILE_URI

The Camera.cleanup method works when there is a picture so that after using this method the camera will clean up the picture/or image. The JavaScript code for some camera.getpicture methods is:

function capturePhoto() {

// Take picture using device camera and retrieve image as base64-encoded string

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,

destinationType: destinationType.DATA_URL

});

}

// A button will call this function

function capturePhotoEdit() {

// Take picture using device camera, allow edit, and retrieve image as base64-encoded string

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true,

destinationType: destinationType.DATA_URL

});

}

// A button will call this function

function getPhoto(source) {

// Retrieve image file location from specified source

navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,

destinationType: destinationType.FILE_URI,

sourceType: source

});

}

The example of camera.cleanup method is as:

navigator.camera.cleanup(onSuccess, onFail);

function onSuccess()
{

console.log("Camera cleanup success.")

}
function
onFail(message)
{

alert('Failed because: ' + message);

}

This article simply shows how to use the camera.cleanup method of camera.