title: navigator.permissions.query alternative for iOS Safari
body: <p>I programmed a script that allows visitors of our website to record audio and then saves the file on our server.</p>
  
  <p>Everything worked perfectly until I noticed, that if a user did not give his permission but presses the recording button anyway, the script crashed. Therefore I included this to make sure that permission was granted:</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-html lang-html prettyprint-override"><code>navigator.permissions.query({name:'microphone'}).then(function(result) {
   if (result.state == 'granted') {
   //GRANTED
   } else if (result.state == 'denied') {
    //DENIED
   }
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Unfortunately, this does not work for iOS Safari and therefore leads to a crash again in this case. I found several threads about this topic but not a single solution for iOS. But there must be one, right? How should we record audio on an iPhone if we cant make sure that the permission was granted and if recording while under denial of microphone access also leads to a crash?</p>
  
  <p>I hope anyone has an Idea. Thanks in advance.
  Daniel</p>