Phonegap ios Camera fails on device not simulator

2019-08-15 18:18发布

问题:

I'm using Phonegap to make a little app for IOS and android that uses the camera of the device and then I upload it with Phonegap Build. The problem is that the camera plugin doesn't seem to work on a device, altho it works on a simulator ( opens up the photolibrary, so I know it works). I use the following code:

navigator.camera.getPicture(uploadPhoto, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI,sourceType:Camera.PictureSourceType.PHOTOLIBRARY});

The device doesn't even go to the onFail function, I believe it doesn't recognize getPicture as a function since it does recognize navigator.camera as an object.

I believe the problem lays somewhere in the config.xml file since if I delete the geolocation plugin ( that works ) it still uses that plugin for some reason.

Here are the things I've put in the xml:

<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="Camera">
        <param name="ios-package" value="CDVCamera" />
    </feature>
<gap: Camera ...> (forgot the syntax)

This might sound vage and I probably left out some important info, but any info you can give me would be greatly appreciated.

回答1:

Years late, but I this may help others in the future: I suspect that the problem here was that Xcode simulator does not support audio and video input as of iOS 8.2, which was shortly before this question was asked.

Though most of the functionality of devices can be simulated in Simulator, some hardware features must be tested directly on a device. The hardware features that are not simulated as of iOS 8.2 are:

Motion support (accelerometer and gyroscope) are unsupported. Audio and video input (camera and microphone) are unsupported.