I'm developing an app using Phonegap Build that needs to take pictures or select one from the gallery. First I'm developing the Android version, but I'm going to need to develope it also for iOS.
I saw a lot of examples around the web (and in the phonegap documentation), but none of them worked for me. First of all, I found four different ways to add the Camera plugin to the config.xml in a lot of different posts:
1:
<plugin name="Camera" value="org.apache.cordova.CameraLauncher" />
2:
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/file"/>
3:
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.camera.CameraLauncher"/>
<param name="ios-package" value="CDVCamera" />
</feature>
4:
<gap:plugin name="org.apache.cordova.camera" />
<gap:plugin name="org.apache.cordova.media-capture" />
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.media" />
<gap:plugin name="org.apache.cordova.device" />
The option number 2 is the only one that worked for me, and I'm saying this because is the only one that after I've generated the APK and try to install in a device (Tried on a Samsung S4 and on a Nexus 7 tablet), it asks for permitions to take pictures and videos and read, modify and delete content of the USB storage. The others, don't. (I also tried different combinations of more than one of this options, even all of them at the same time).
By the way I'm using the current version of Phonegap that the Build at this time (28 apr 2015) states that is 3.7 (I also tried forcing version 3.3 but saw no difference).
I tried several codes inside my app, I'm not going to write all the examples down here because I think it makes not point because they're all the same at the root (navigator.camera.getPicture), for example:
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50 });
Well, the "navigator.camera.getPicture" always send me the same error after a Try-catch: Camera is not defined.
I've included the phonegap.js (not the file but the reference in the html) as stated in Phonegap Build Documentation by adding:
<script src="phonegap.js"></script>
and also tried with:
<script src="cordova.js"></script>
Also tried not including any reference to the phonegap API. (Just in case?!)
It has been 4 days searching and trying different things, if anybody has any clue, it would be greatly appreciated.
Thanks, and sorry for my english.
///////////////////////////////////////////////////////////////////////////////
RESOLUTION:
It had to be a problem with the Phonegap Build Server. Because at the moment I wrote this post I was trying to compile the app without success because of the server was down, so I started working with other things. Today I've recompiled the app, without modifing anything and now it works (The camera). By the way I went with option nº4, don't know if the other ones work.