ios - Phonegap Camera Api won't work (failed to load resource) -


i'm using phonegap version 3.

i installed cordova , phonegap, reason console shows phonegap.js , cordova.js fail load. not in js folder either thought pretty weird, phonegap has worked me, until today when tried use camera api function. ran plugin install commands camera , added config.xml file:

<feature name="camera">     <param name="ios-package" value="cdvcamera" /> </feature> 

but camera not work in ios emulator nor work on web browser. in web console i'm getting these errors.

failed load resource: requested url not found on server: file:///users/thomas/dev/myapp/www/cordova.js

and when click on of buttons error

typeerror: 'undefined' not object (evaluating 'navigator.camera.getpicture')

here code: (copied straight phonegap website)

<!doctype html> <html>   <head>     <title>capture photo</title>      <script type="text/javascript" charset="utf-8" src="cordova.js"></script>     <script type="text/javascript" charset="utf-8">      var picturesource;   // picture source     var destinationtype; // sets format of returned value      // wait device api libraries load     //     document.addeventlistener("deviceready",ondeviceready,false);      // device apis available     //     function ondeviceready() {         picturesource=navigator.camera.picturesourcetype;         destinationtype=navigator.camera.destinationtype;     }      // called when photo retrieved     //     function onphotodatasuccess(imagedata) {       // uncomment view base64-encoded image data       // console.log(imagedata);        // image handle       //       var smallimage = document.getelementbyid('smallimage');        // unhide image elements       //       smallimage.style.display = 'block';        // show captured photo       // inline css rules used resize image       //       smallimage.src = "data:image/jpeg;base64," + imagedata;     }      // called when photo retrieved     //     function onphotourisuccess(imageuri) {       // uncomment view image file uri       // console.log(imageuri);        // image handle       //       var largeimage = document.getelementbyid('largeimage');        // unhide image elements       //       largeimage.style.display = 'block';        // show captured photo       // inline css rules used resize image       //       largeimage.src = imageuri;     }      // button call function     //     function capturephoto() {       // take picture using device camera , retrieve image base64-encoded string       navigator.camera.getpicture(onphotodatasuccess, onfail, { quality: 50,         destinationtype: destinationtype.data_url });     }      // button call function     //     function capturephotoedit() {       // take picture using device camera, allow edit, , retrieve image base64-encoded string       navigator.camera.getpicture(onphotodatasuccess, onfail, { quality: 20, allowedit: true,         destinationtype: destinationtype.data_url });     }      // button call function     //     function getphoto(source) {       // retrieve image file location specified source       navigator.camera.getpicture(onphotourisuccess, onfail, { quality: 50,         destinationtype: destinationtype.file_uri,         sourcetype: source });     }      // called if bad happens.     //     function onfail(message) {       alert('failed because: ' + message);     }      </script>   </head>   <body>     <button onclick="capturephoto();">capture photo</button> <br>     <button onclick="capturephotoedit();">capture editable photo</button> <br>     <button onclick="getphoto(picturesource.photolibrary);">from photo library</button><br>     <button onclick="getphoto(picturesource.savedphotoalbum);">from photo album</button><br>     <img style="display:none;width:60px;height:60px;" id="smallimage" src="" />     <img style="display:none;" id="largeimage" src="" />   </body> </html> 

i think missing www folder correct structure. right not on office check names but:

<root_folder_name> / wwww                index.html                      /camera                              index.html                    /plugins                          /<camera plugin name>                                                /test                   /platform                        /ios                            /<projectname>.xcodeproj 

or similar structure should have. anyhow, from: plugins / <camerapluginmane> /test/ copy index.html , camera folder index.html root www folder.

also need main.css main.js , cordova-incl.js files @ test folder.

just double check /test/index.html source , make structure , files available @ www root folder.

tomorrow or monday can in office edit answer , correct names.

your error: "typeerror: 'undefined' not object (evaluating 'navigator.camera.getpicture'" @ web part ( www structure) , code calling didn't went ios files ( .h .m ) yet!

i hope helps!


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -