Search code examples
androidioscordovacordova-plugin-camera

cordova navigator.camera is undefined


I have installed cordova-plugin-camera. Although, it gives me the following error.

navigator.camera is not defined. Here is the code snippet. Thanks in advance!

 <body>
    <script>
       document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady() {
            console.log(typeof navigator.camera);
        }
    window.onload=onDeviceReady;
    </script>

</body>

Solution

  • Remove the window.onload=onDeviceReady;

    You are calling onDeviceReady twice, once before device is ready and then when it's ready.