Page 1 of 2

How to get activate the camera and take a picture?

Posted: Thu May 17, 2012 5:48 pm
by Will4455852

Hello all,
I have a question about the camera and calling the Phonegap API directly. I was following the tutorial on this site about using the camera and have had no luck getting it to work. I click the button that should open the camera application but nothing happens. Thinking it was possible the tutorial was out of date, I went over to the phonegap api documents and tried their example. I get the same result (i.e. nothing happens).

Here is my setup:

I have a simple button with a click event which calls this function:
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
alert("clicked button");
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50 });
}

For testing I put the alert into the function to be sure the function was called. I also put an alert in the "onPhotoDataSuccess" function, however that function was never called. I have a feeling that calling the native phonegap api needs to be done differently, but I am not sure how.

Any thoughts?


How to get activate the camera and take a picture?

Posted: Thu May 17, 2012 6:35 pm
by maxkatz

Here is what I did and it worked. I added the Camera component (from Device palette) into the page. Invoke the service on button click and it worked (I didn't do any output mappings, just was testing if the camera will open).


How to get activate the camera and take a picture?

Posted: Thu May 17, 2012 7:18 pm
by Will4455852

Interesting, this did not work for me. When I tap the button, nothing happens. Is it possible there is an issue with creating the release binary using build.phonegap.com instead of the one built into tiggzi? I am using that service as my certificates are already installed there and it makes testing apps on the iphone pretty painless.


How to get activate the camera and take a picture?

Posted: Thu May 17, 2012 7:26 pm
by maxkatz

I tested the app using Tiggzi Mobile Tester, on Android.


How to get activate the camera and take a picture?

Posted: Thu May 17, 2012 7:34 pm
by Will4455852

So is this an iphone related issue? The other thing I have noticed is the 'deviceready' event never fires when the app loads. Is this too an iphone related issue?


How to get activate the camera and take a picture?

Posted: Thu May 17, 2012 8:54 pm
by maxkatz

It should work the same way on iOS. Are you using the Camera component or the PhoneGap API directly?


How to get activate the camera and take a picture?

Posted: Thu May 17, 2012 10:20 pm
by Will4455852

I have tried both the component and the Phonegap API.


How to get activate the camera and take a picture?

Posted: Fri May 18, 2012 4:06 am
by maxkatz

We'll test this.


How to get activate the camera and take a picture?

Posted: Fri May 18, 2012 3:34 pm
by maxkatz

We tested on iOS, and the camera works. If you would like us to test more, please share your app for collaboration with a href="mailto:support@tiggzi.com" rel="nofollow"support@tiggzi.com/a.


How to get activate the camera and take a picture?

Posted: Fri May 18, 2012 4:10 pm
by Will4455852

Ok, I have shared with support. It is a VERY simple app. One button which invokes the camera. When I test on my ios device, nothing happens.

Keep in mind that I am building the release binary via build.phonegap.com not the internal builder (as all apps I build via your builder, will not install on my ios device).

Any help would be greatly appreciated.