title: Accessing microphone with the help of getUsermedia on iOS Safari
body: <p>I'm attempting to access the microphone on iOS Safari with the help of the getUserMedia. Below you can find a snippet of my code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>if (navigator.mediaDevices === undefined) {
    navigator.mediaDevices = {};
  }
  
  if (navigator.mediaDevices.getUserMedia === undefined) {
    navigator.mediaDevices.getUserMedia = function(constraints) {
      // First get ahold of the legacy getUserMedia, if present
      let getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
  
      // Some browsers just don't implement it - return a rejected promise with an error
      // to keep a consistent interface
      if (!getUserMedia) {
        return Promise.reject(new Error('getUserMedia is not implemented in this browser'));
      }
  
      // Otherwise, wrap the call to the old navigator.getUserMedia with a Promise
      return new Promise(function(resolve, reject) {
        getUserMedia.call(navigator, constraints, resolve, reject);
      });
    }
  }
  
  navigator.mediaDevices.getUserMedia({
    audio: true
  }).then(function(stream) {
    successCallBack(.......);
  }).catch(function(error) {
    debug.log(error);
    ..........
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Yet the promise always catches an error, to be more specific an OverConstraintError.</p>
  
  <pre><code>{message: "Invalid constraint", constraint: ""}
  </code></pre>
  
  <p>This behaviour is unique for iOS Safari, on all other browsers (Chrome, Firefox, Safari osX) it works without any problem. Actually my issue ressembles a lot like this one => <a href="https://stackoverflow.com/questions/46981889/how-to-resolve-ios-11-safari-getusermedia-invalid-constraint-issue">How to resolve iOS 11 Safari getUserMedia &quot;Invalid constraint&quot; issue</a>, yet I'm not trying to use the camera. The only thing that interests me is the microphone.</p>
  
  <p>I'm testing with a real iPhone (a 5 and X, both updated to the latest version), so it is not linked to the iPhone Simulator. </p>
  
  <p>The access to the microphone is granted and the popup requesting permissions is also showing, so it is not an permissions issue.</p>