title: Meteor Cordova: Cannot get camera plugin to work, Uncaught TypeError: Cannot read property 'getPicture' of undefined
body: <p>I am trying out the Meteor Cordova camera plugin and it won't work, and I have no idea what I'm missing. </p>
  
  <p>Here is what I did:</p>
  
  <ol>
  <li><p>Meteor create new project</p></li>
  <li><p>Added the cordova camera package <code>meteor add cordova:org.apache.cordova.camera@0.3.1</code></p></li>
  <li><p>Programmed the default button on screen to take a picture and then append it to the body.<br>
  This should use the camera built into the laptop computer but all I get when I click the button is: <code>Uncaught TypeError: Cannot read property 'getPicture' of undefined</code>  </p>
  
  <p>And when I run the app in the iPhone simulator with the command <code>meteor run ios</code> and click the button I get a popup error: <code>Failed because: no camera available</code></p></li>
  </ol>
  
  <p>This is what my html and js file look like:</p>
  
  <p><strong>main.html</strong>:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;head&gt;
    &lt;title&gt;cameraTest&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;h1&gt;Welcome to Meteor!&lt;/h1&gt;
  
    {{&gt; hello}}
  &lt;/body&gt;
  
  &lt;template name="hello"&gt;
    &lt;button&gt;Click Me&lt;/button&gt;
    &lt;p&gt;You've pressed the button {{counter}} times.&lt;/p&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p><strong>main.js</strong>:</p>
  
  <pre class="lang-js prettyprint-override"><code>if (Meteor.isClient) {
    // counter starts at 0
  
    function onSuccess(imageData) {
        var image = document.getElementById('myImage');
        image.src = "data:image/jpeg;base64," + imageData;
        $('body').append(image);
    }
  
    function onFail(message) {
        alert('Failed because: ' + message);
    }
  
    Session.setDefault("counter", 0);
  
    Template.hello.helpers({
      counter: function () {
        return Session.get("counter");
      }
    });
  
    Template.hello.events({
      'click button': function () {
  
        navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
          destinationType: Camera.DestinationType.DATA_URL
        });
      }
    });
  }
  </code></pre>