Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Felipe_X_
Beginner
91 Views

Camera error on iOS

Well guys, okay?

I have a difficulty here on the camera's cord using Intel XDK. Next, when I click the button that calls the mobile camera in android, works normal, now when I click an iOS of the following error: "TypeError: undefined is not an object (Evaluating 'navigator.camera.getPicture')"

Could someone help me with this?

source code:

var windowHeight;
var init = function () {
    windowHeight=window.innerHeight; 
};

var preventDefaultScroll = function(event) {
    event.preventDefault();
    window.scroll(0,0);
    return false;
};

var onDeviceReady=function() {    
    screen.lockOrientation('portrait');
    if( window.Cordova && navigator.splashscreen ) {     
        navigator.splashscreen.hide() ;                
    }
};

function onSuccess(imageURI) {
    var pic1 = document.getElementById("foto");
    var changebutton = document.getElementById("tirarFoto");    
    pic1.src = imageURI;
}

function onFail(message) {}

function takepicture() {
    navigator.camera.getPicture(onSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI, saveToPhotoAlbum: true });
    screen.lockOrientation('portrait');
} 

window.addEventListener("load", init, false);  
window.document.addEventListener("touchmove", preventDefaultScroll, false);
document.addEventListener("deviceready", onDeviceReady, false);

 

Tags (2)
0 Kudos
3 Replies
Swati_S_Intel1
Employee
91 Views

Which version of camera plugin are you using? And on what iOS version? Try the  Image Capture app from the Samples and Demos.

Felipe_X_
Beginner
91 Views

Demos don't worked too.

plugin camera version 2.1.0

iOS version 9.3.2

what do I work ?!

Swati_S_Intel1
Employee
91 Views

Felipe, I just tried the camera demo app on my iPhone 6s with iOS version 9.3 and it works fine. Your plugin version is correct. Is it possible you did not give access to camera when the app launched? You should have gotten a prompt to allow access to camera when you launched the app first time. If you skipped that step, please go in iOS settings, select your app and allow access to camera. Also, make sure you are not using any other camera plugin (just the plugin from the Core plugins list) that could conflict. The Camera app from the demo apps should work out of the box. I would delete any of your camera apps that you installed previously on your device, create a new app in XDK from samples and demo and build again. Please try again a fresh, it should work.

Reply