У меня есть кнопка, которая onclick класса функция getImage(); и он падает, когда я вызываю это на моем iphone 7 плюс, у которого есть ios 10. Может кто-то, пожалуйста, скажите мне, почему это происходит, и дайте мне правильный код, чтобы остановить это. Вот код, который у меня есть на данный момент, который использовался для работы и работает над более старыми ios и Android.PhoneGap камера не работает на ios 10
navigator.camera.getPicture функция сбоев на устройстве ios 10.
function getImage() {
// Retrieve image file location from specified source
navigator.camera.getPicture(uploadPhoto,
function(message) {
alert('get picture failed');
}, {
quality: 80,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
correctOrientation : true,
allowEdit: true
}
);
}
function uploadPhoto(imageURI) {
//function sendPhoto(filetype){
var options = new FileUploadOptions();
options.fileKey="file";
//get file name
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
//Check if the device is android or not and if it is use the folowing code
var devicePlatform = device.platform;
if(devicePlatform == "Android"){
//check file extension
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1)+".jpeg";
}
var params = new Object();
params.value1 = "Babatunde";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "uploadUserPhoto.php", win, fail, options);
//Part of the commment out function sendPhoto
//}
}
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
alert(r.response);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
}
Вы добавили разрешение на доступ камеры в файл 'info.plist'? См. Этот ответ: http://stackoverflow.com/a/38498347/6449750 –