Reputation: 63
Using cordova 2.8.1 I am trying to do a camera.getPicture with photolibrary. It seems to be working for android but not for iOS. below is how I call the getPicture code. On an iPhone 4s with iOS 6 it allows me to select an image, but as soon as thats done the error callback is called with the argument being null
var options = {
quality : 30,
destinationType : Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
correctOrientation: true,
targetWidth: 800,
targetHeight: 800
};
navigator.camera.getPicture(this.captureSuccessPre, this.captureError, options);
I was told to add a timeout around the console.logs. On phonegaps documentation it states to do so around alerts. Below is my error callback. which logs [error null]
captureError: function(error){
setTimeout(function(){
console.log("error " + error); //logs error null
}, 100);
}
Anyone have any ideas. I have been struggling for a few days. If it helps any this code works perfect with
sourceType : Camera.PictureSourceType.CAMERA,
Upvotes: 3
Views: 2668
Reputation: 376
Try this it will helping for you
function uploadFromGallery(){
navigator.camera.getPicture(uploadPhoto,function(message){
console.log('get picture failed'); },
{quality: 75,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType:navigator.camera.PictureSourceType.PHOTOLIBRARY,
allowEdit:true,
targetWidth: 100,
targetHeight: 100
});
}
Upvotes: 0
Reputation: 1052
Looks like there was a bug in 2.8.0 - if you upgrade to 2.9.0 it fixes it ([CB-3757] camera.getPicture from photolib fails on iOS - https://github.com/phonegap/phonegap/blob/2.9.0/changelog)
Upvotes: 2
Reputation: 126
I have exactly the same problem; seems to be related to the DestinationType.FILE_URI.
Try this:
var options = {
quality : 30,
destinationType: navigator.camera.DestinationType.NATIVE_URI,
sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
correctOrientation: true,
targetWidth: 800,
targetHeight: 800
};
Upvotes: 9