Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Phonegap error camera
Thu, Jun 7 2018 8:57 AMPermanent Link

Pasquale

Web Pos srl

I'm working with phonegap to manage a camera. On the OnClick event does not open the camera but I see the error "Cannot read property 'getPicture' of undefined".
It depends on the config.xml?
Thu, Jun 7 2018 9:33 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

You need something like this in the config.xml file to access the camera
or photos via Cordova/Phonegap

<plugin name="cordova-plugin-camera" source="npm">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to
access the camera." />
    <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App would
like to access the library." />
    <variable name="MICROPHONE_USAGE_DESCRIPTION" value="App would like
to access the microphone." />
</plugin>

and something like this in an external javascript file:

function capturePhoto(onPhotoSuccess,onPhotoFail)
{
  navigator.camera.getPicture(onPhotoSuccess, onPhotoFail, {
                saveToPhotoAlbum: true,
                quality : 50,
                  allowEdit : false,
                  destinationType : Camera.DestinationType.FILE_URL,
                  sourceType : Camera.PictureSourceType.CAMERA,
                  encodingType: Camera.EncodingType.JPEG,
                saveToPhotoAlbum: true
            });
}


On 07/06/2018 13:57, Pasquale wrote:
> I'm working with phonegap to manage a camera. On the OnClick event does not open the camera but I see the error "Cannot read property 'getPicture' of undefined".
> It depends on the config.xml?
>
Image