Software Archive
Read-only legacy content
17061 Discussions

Camera error on iOS

Felipe_X_
Beginner
728 Views

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);

 

0 Kudos
3 Replies
Swati_S_Intel1
Employee
728 Views

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

0 Kudos
Felipe_X_
Beginner
728 Views

Demos don't worked too.

plugin camera version 2.1.0

iOS version 9.3.2

what do I work ?!

0 Kudos
Swati_S_Intel1
Employee
728 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.

0 Kudos
Reply