Reputation: 415
I am trying to access Cordova's camera plugin from my Mobile Angular UI project.
navigator.geolocation is working find along with all of the other Cordova stuff but when I try to access navigoator.camera it comes back as undefined.
When I console.log(navigator) camera is not included:
The plugin was installed with the following command and it is in my plugins folder:
cordova plugin add cordova-plugin-camera
I'm currently trying to access it with a factory like this:
angular.module('App.services.Camera', [
'App.services.Cordova'
])
.factory('openCamera', function(deviceReady, $document, $window, $rootScope){
return function(done) {
deviceReady(function() {
var srcType = Camera.PictureSourceType.CAMERA;
var options = setOptions(srcType);
var func = createNewFileEntry;
navigator.camera.getPicture(function cameraSuccess(imageUri) {
$rootScope.$apply(function(){
done(imageUri);
});
displayImage(imageUri);
func(imageUri);
}, function cameraError(error) {
console.debug("Unable to obtain picture: " + error, "app");
}, options);
});
};
});
Do I need to reference the plugin somewhere to add it to my project or am I installing the plugin the wrong way?
Upvotes: 0
Views: 1095
Reputation: 136
Quick checklist.
Do you add the plug-in in the config. xml? (if not, added. This will review in each build if the plug-ins were installed for the platform)
Do you test in a real device? Plug-in will not work on browsers (this is what I think happened, so please run on device: ionic run android
)
Upvotes: 1