Phonegap Cordova 3.0.0 navigator.camera не определена

Я пытаюсь использовать родные плагины Cordova в первый раз. Я начал с камеры и примера кода, приведенного в документации. Это терпит неудачу однако иnavigator.camera не определено

мы включили код ниже.




var pictureSource;   // picture source
var destinationType; // sets the format of returned value

// Wait for device API libraries to load
//
document.addEventListener("deviceready",onDeviceReady,false);

// device APIs are available
//
function onDeviceReady() {
    pictureSource=navigator.camera.PictureSourceType;
    destinationType=navigator.camera.DestinationType;
}

// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageData) {
  alert("Photo Data Success");
  // Uncomment to view the base64-encoded image data
  // console.log(imageData);

  // Get image handle
  //
  var smallImage = document.getElementById('smallImage');

  // Unhide image elements
  //
  smallImage.style.display = 'block';

  // Show the captured photo
  // The inline CSS rules are used to resize the image
  //
  smallImage.src = "data:image/jpeg;base64," + imageData;
}

// A button will call this function
//
function capturePhoto() {
  alert("function is called"); 
  if(_.isUndefined(navigator.camera)){
    alert("Camera is not defined");
  }else{
    alert("WTF?!");
  }
  // Take picture using device camera and retrieve image as base64-encoded string
  navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
    destinationType: destinationType.DATA_URL });
}

// Called if something bad happens.
//
function onFail(message) {
  alert('Failed because: ' + message);
}



Capture Photo <br>
<img style="display:none;width:60px;height:60px;" id="smallImage" src="">
<img style="display:none;" id="largeImage" src="">

Я установил плагин камеры в соответствии с инструкциями CLI

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git

Я также добавил файлы cordova.js.


Ответы на вопрос(5)

Ваш ответ на вопрос