Search code examples
javascripthtmlcordovaphonegap-build

Can't use navigator.camera.getPicture on iOS phonegap adobe build


I have been looking for hours now and can't get my phonegap app (compiled by adobe phonegap build) and I fear I am missing something about phonegap. I have added the following lines to the config.xml file:

<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="Camera">
    <param name="ios-package" value="CDVCamera" />
</feature>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/camera"/>

I try to take the picture using the following code:

navigator.camera.getPicture(function(image) {callback("data:image/jpeg;base64," + image)}, cameraFail, { quality: 49 }); 

I am testing it by running it on an iPad2 running iOS 7. I've created a rudimentary inapp console and the problem appears to be that navigator.camera does not exist. Thanks for reading hope you can help.


Solution

  • With help from another answer it lead me to realize what I had done wrong so i'll post for anyone else that is in the same boat.

    I hadn't included a reference to cordova.js which should be done just by adding a normal script tag like this:

    <script src="cordova.js"></script>
    

    I hadn't included it as I did not have the file cordova.js. What I did not realize is when using the adobe Phonegap Build service the file is added automatically and I did not need it in my source directory, just to include the tag.