클래스에 onclick 버튼 getImage()가 있습니다. 내가 내 아이폰 7 플러스에 ios 10을 호출하면 충돌이 발생합니다. 누군가가 왜 이런 일이 일어나고 있는지 알려주고 이것을 막을 올바른 코드를 제공 할 수 있습니까? 여기에 오래된 코드와 안드로이드에서 작동하고 작업하는 데 사용 된 코드가 있습니다.PhoneGap 카메라가 작동하지 않습니다.
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 –