question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getUserMedia is not defined (Android/iOS)

See original GitHub issue

I have an Ionic 2( Based on Angular2+) App which uses QuaggaJS to Stream the Camera to my View (Div Container) like Snapchat to scan QR Codes. In the browser, it all works like a charm but, the moment it gets built as APK or IPA file I’m getting the Error.

Android:

chromium: [INFO:CONSOLE(76955)] "Error: getUserMedia is not defined"

I used ADB and a Virutal Android Device to get the logcat output. Important Info: Yes I have all Permissions and yes my Device is on Android 7.0 (because WebRTC is only supported on 5.0+)!

iOS:

Error: getUserMedia is not defined

And yes I have iOS 11 Beta 3 installed on my Device (because WebRTC is only supported on iOS 11)! Here a picture of the error output on my mac (Sorry for the bad quality).

ios error

Browser:

Everything works perfekt!

Code Snippet:

As you can see above the error it states

ERRORINFO: SetUp QuaggaJS

This is a Console Output which is generated by myselfe to locate the error. So the error must be here in this codesnippet:

   Quagga.init({
         inputStream : {
             name : "Live",
             type : "LiveStream",
             constraints: {
               width:  window.innerWidth,
               height: window.innerHeight,
               facingMode: "environment"
             },
             area: {
                top: "0%",
                right: "0%",
                left: "0%",
                bottom: "0%"
            },
           target: document.querySelector('#scanner')
         },
         locator: {
           patchSize: "medium",
           halfSample: true
         },
         numOfWorkers: (navigator.hardwareConcurrency ? navigator.hardwareConcurrency : 4),
         decoder : {
          readers: [ "code_128_reader",
                     "ean_reader",
                     "ean_8_reader",
                     "code_39_reader",
                     "code_39_vin_reader",
                     "codabar_reader",
                     "upc_reader",
                     "upc_e_reader",
                     "i2of5_reader" ],
         },
         locate: true
       }, function(err) {
           if (err) {
               console.error("ERRORINFO: SetUp von QuaggaJS");
               console.error(err);
               return
           }
           console.log("Initialization finished. Ready to start");
           Quagga.start();
       });

And for me it looks like the error gets triggered in this line:

target: document.querySelector('#scanner')

#scanner is just an div container for the livestream (as I said it works in browser, but just if you wonder what scanner is):

<div id="scanner" ion-fixed class="scannerdiv">
</div>

What have I tried?

As you mentioned in your documentary:

Every browser seems to differently implement the mediaDevices.getUserMedia API. Therefore it’s highly recommended to include webrtc-adapter in your project.

So I installed it with npm. But that didnt work, so after that I imported it directly in my index.html like this:

<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>

Well that didnt work either. @serratus

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14

github_iconTop GitHub Comments

5reactions
poliandercommented, Dec 20, 2017

I can confirm that Quagga definitely works on iOS 11 (at least with WebRTC adapter.js included).

1reaction
lreinercommented, Aug 7, 2017

Update:

I found out that on iOS it doesnt have premissions for the camera. Well I set the premissions in code and on Android it works but it seems on iOS I must call the premissions in lifetime to ask the user to access the camera.

So I’m searching for a Ionic/Cordova Plugin which ask users in lifetime to gain premissions for Camera, Storage and Audio. If that worked I’ll post it here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript/Angular2 getUserMedia is not defined
1) Important: Accessing getUserMedia requires a secure origin in most browsers, meaning that http:// can only be used on localhost.
Read more >
Developers - getUserMedia is not defined (Android/iOS) -
Coming soon: A brand new website interface for an even better experience!
Read more >
MediaDevices.getUserMedia() - Web APIs | MDN
getUserMedia () method prompts the user for permission to use a ... mediaDevices will be undefined , and you cannot use getUserMedia() ....
Read more >
TypeError: null is not an object (evaluating 'WebRTCModule ...
I'm building an React-native-app with openvidu, I've already went through the tutorial and even tested the demo, and made some changes to ...
Read more >
WebRTC Fix For getUserMedia Undefined On Local Hosts
WebRTC Fix For getUserMedia Undefined On Local Hosts. You're in the process of building a video or audio app that is going to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found