javascript - Can't use navigator.camera.getPicture on iOS phonegap adobe build - Stack Overflow

I have been looking for hours now and can't get my phonegap app (piled by adobe phonegap build) an

I have been looking for hours now and can't get my phonegap app (piled by adobe phonegap build) and I fear I am missing something about phonegap. I have added the following lines to the config.xml file:

<feature name=".0/geolocation"/>
<feature name="Camera">
    <param name="ios-package" value="CDVCamera" />
</feature>
<feature name=".0/file"/>
<feature name=".0/camera"/>

I try to take the picture using the following code:

navigator.camera.getPicture(function(image) {callback("data:image/jpeg;base64," + image)}, cameraFail, { quality: 49 }); 

I am testing it by running it on an iPad2 running iOS 7. I've created a rudimentary inapp console and the problem appears to be that navigator.camera does not exist. Thanks for reading hope you can help.

I have been looking for hours now and can't get my phonegap app (piled by adobe phonegap build) and I fear I am missing something about phonegap. I have added the following lines to the config.xml file:

<feature name="http://api.phonegap./1.0/geolocation"/>
<feature name="Camera">
    <param name="ios-package" value="CDVCamera" />
</feature>
<feature name="http://api.phonegap./1.0/file"/>
<feature name="http://api.phonegap./1.0/camera"/>

I try to take the picture using the following code:

navigator.camera.getPicture(function(image) {callback("data:image/jpeg;base64," + image)}, cameraFail, { quality: 49 }); 

I am testing it by running it on an iPad2 running iOS 7. I've created a rudimentary inapp console and the problem appears to be that navigator.camera does not exist. Thanks for reading hope you can help.

Share Improve this question asked Jan 4, 2014 at 18:11 user1044220user1044220 3711 gold badge7 silver badges21 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

With help from another answer it lead me to realize what I had done wrong so i'll post for anyone else that is in the same boat.

I hadn't included a reference to cordova.js which should be done just by adding a normal script tag like this:

<script src="cordova.js"></script>

I hadn't included it as I did not have the file cordova.js. What I did not realize is when using the adobe Phonegap Build service the file is added automatically and I did not need it in my source directory, just to include the tag.

Installing plugins for PhoneGap can be difficult.

Do you have the following functions in your code?

navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
    destinationType: Camera.DestinationType.DATA_URL
 }); 

function onSuccess(imageData) {
    var image = document.getElementById('myImage');
    image.src = "data:image/jpeg;base64," + imageData;
}

function onFail(message) {
    alert('Failed because: ' + message);
}

Your config.xml seems ok.

Also, check the following links:

https://build.phonegap./plugins/242

https://github./apache/cordova-plugin-camera/tree/fed4f2280d786cabb24641eb6ce686acf98d0a94 (Contains test folder so you can test it on your device)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743657383a4485608.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信