2016-12-16 3 views
2

클래스에 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); 
    } 
+0

에 'info.plist' 파일에 카메라 액세스 권한을 추가 했습니까? 이 답변 참조 : http://stackoverflow.com/a/38498347/6449750 –

답변

2

당신은 아이폰 OS 10

카메라에 대한의 Info.plist에이 권한을 추가해야합니다 :

키 : 개인 정보 보호 - 카메라 사용법 설명
값 : $ (PRODUCT_NAME) 카메라 사용

사진 :

키 : 개인 정보 보호 - 사진 라이브러리 사용법 설명
값 : $ (PRODUCT_NAME) 사진 사용

0

이유 iOS10에서가 아니라 당신이 카메라 및 앨범에 대한 사용 권한을 추가해야하기 때문에 이전이 버전의 응용 프로그램이 충돌합니다. 당신은 당신의 info.plist

사진에 권한을 추가해야합니다

Key  : Privacy - Photo Library Usage Description  
Value : $(PRODUCT_NAME) photo use 

카메라 : 당신이 당신의 Info.plist에 지정해야 키의 목록

Key  : Privacy - Camera Usage Description 
Value : $(PRODUCT_NAME) camera use 

Apple's documentation

관련 문제