I've created an Ionic app and I need the camera functionality so that a user can take a picture and send it to a webservice. I've followed the following guide by Ionic.
Basically you just cd
into your applicatoin
cd myApp
then you run
cordova plugin add org.apache.cordova.camera
and once the plugin has been installed, you can invoke it's functionality where ever in your app (because according to Cordova, navigator.camera
is a global object). In my case I'm just doing it in one of my controllers where the following function gets called after a button click using ng-click
:
$scope.takePhoto = function() {
navigator.camera.getPicture(function(imageURI) {
// imageURI is the URL of the image that we can use for
// an <img> element or backgroundImage.
}, function(err) {
// Ruh-roh, something bad happened
}, cameraOptions);
}
But it does nothing.. Now I've followed what Ionic said I must do to a 'T' and nothing more. Is there anything else I should be doing? Editing the config.xml
perhaps? It's probably worth mentioning that this is the first time I've attempted in using a Cordova plugin of any sort.