iphone-5phonegap-desktop-app

PhoneGap developer app - not able to connect to my camera


I have an issue with the PhoneGap desktop app. I wrote a piece of code that accesses the device camera. Using the PhoneGap desktop app it doesn't access the camera on my iPhone. When I build the same code using build.phonegap.com it does access the camera. Here is my code and config.xml files:

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

Solution

  • Make sure that you link to cordova.js