2016-01-04 1 views
1

У меня проблема с настольным приложением PhoneGap. Я написал фрагмент кода, который обращается к камере устройства. Используя настольное приложение PhoneGap, он не имеет доступа к камере на моем iPhone. Когда я строю тот же код, используя build.phonegap.com, он делает доступ к камере. Вот мой код и config.xml файлы:Приложение разработчика PhoneGap - невозможно подключиться к моей камере

// Get the picture from the camera 
    function getPicture() {    
     if ($("#radio-view-b").attr('checked')) 
      sourceType = navigator.camera.PictureSourceType.PHOTOLIBRARY; 
     else 
      sourceType = navigator.camera.PictureSourceType.CAMERA;    
      params = { 
       quality: 50, // from 0 to 100 - size vs. quality 
       destinationType: navigator.camera.DestinationType.FILE_URI, 
       sourceType: sourceType 
       } 
      navigator.camera.getPicture(uploadPhoto, // ** PG ** 
       function (message) { alert('camera.getPicture failed'); }, 
       params 
       ); 

    } 

    // Upload the photo to the server 
    function uploadPhoto(imageURI) { 
     var options = new FileUploadOptions(); // PhoneGap options object 
     options.fileKey="file"; 
     options.fileName = imageName; // file name 
     options.mimeType="image/jpeg"; // file type 
     var params = {}; // Optional parameters in case you need to pass 
     options.params = params; // add parameters to the FileUploadOptions 
     var ft = new FileTransfer(); // ** PG ** 
     var serverUrl = "http://......../ReturnValue.ashx"; // my URL 
     ft.upload(imageURI, encodeURI(serverUrl), uploadSuccess, uploadFail, options); // Upload 
    }// Upload Photo 

    // Loading Successful 
    function uploadSuccess(resp) { 
     alert("success"); 
    } 


    // Loading Failed 
    function uploadFail(error) { 
     alert("failed"); 
    } 

Config.xml:

<widget xmlns  = "http://www.w3.org/ns/widgets" 
     xmlns:gap = "http://phonegap.com/ns/1.0" 
     id  = "il.ac.ruppin.pictureUploadApp" 
     version = "1.0.0"> 

    <name>Picture Upload App</name> 

    <description> 
     Take a picture and upload it to the server 
    </description> 

    <author href="http://...." email=""> 
     Author 
    </author> 

    <gap:platform name="ios" /> 
    <gap:platform name="android" /> 

    <preference name="phonegap-version"   value="3.6.3" />   
    <preference name="orientation"    value="default" />   
    <preference name="target-device"    value="universal" />  
    <preference name="fullscreen"     value="true" />   
    <preference name="webviewbounce"    value="true" />   
    <preference name="prerendered-icon"   value="true" />   
    <preference name="stay-in-webview"   value="false" />   
    <preference name="ios-statusbarstyle"   value="black-opaque" /> 
    <preference name="detect-data-types"   value="true" />   
    <preference name="exit-on-suspend"   value="false" />   
    <preference name="show-splash-screen-spinner" value="true" />   
    <preference name="auto-hide-splash-screen" value="true" />   
    <preference name="disable-cursor"    value="false" />   
    <preference name="android-minSdkVersion"  value="7" />    
    <preference name="android-installLocation" value="auto" />   

    <gap:plugin name="com.synconset.imageresizer" version="0.1.1" /> 
    <icon src="icon.png" /> 
    <gap:config-file platform="ios" parent="CFBundleShortVersionString"> 
     <string>100</string> 
    </gap:config-file> 
    <access origin="*"/> 
</widget> 

ответ

0

Убедитесь, что вы ссылаетесь на cordova.js

Смежные вопросы