PhoneGap开发者应用程序 - 无法连接到我的相机

时间:2016-01-04 08:02:52

标签: iphone-5 phonegap-desktop-app

我的PhoneGap桌面应用有问题。我写了一段访问设备相机的代码。使用PhoneGap桌面应用程序,它无法访问我的iPhone上的相机。当我使用build.phonegap.com构建相同的代码时,它会访问相机。 这是我的代码和config.xml文件:

    // 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>

1 个答案:

答案 0 :(得分:0)

确保链接到cordova.js