-
Notifications
You must be signed in to change notification settings - Fork 85
Camera Service
This service accesses the device camera and get picture.
#Using the service
##Prerequisites
This only works on the Widget side of a plugin. On the widget page you need to include scripts/buildfire/services/camera/camera.js
:
<script src="../../../scripts/buildfire/services/camera/camera.js"></script>
##Implementation
A new namespace becomes avaiable buildfire.services.camera
. This represents a singleton object camera
###Methods:
buildfire.services.camera.getPicture(options, callback)
this will open the device's default camera application that allows users to snap pictures by default. It may also ask the user for permission to access the Camera if it hasn't previously.
-
options
: this is an object containing the various options available https://github.com/apache/cordova-plugin-camera#cameracameraoptions--object -
callback
: callback function that provides the image data or err incase there is an error
buildfire.services.camera.getPicture({},
function (err, imageData) {
if (imageData) {
document.getElementById("imgPic").src = imageData;
}
else {
console.log("no image selected: " + err);
}
}
);