<p dir="auto"><a href="https://github.com/electron/electron/files/7607143/my-app.zip">my-app.zip</a></p>
<p dir="auto"><a href="https://user-images.githubusercontent.com/93366473/143543414-e233dfac-3973-4c84-8aea-bcfbb2841b51.png" rel="nofollow">Annotation 2021-11-26 130117</a>)</p>
<p dir="auto">This is my code and permission function inside renderer folder -&gt; helpers -&gt; permission.jsx</p>
<p dir="auto">and permission function use inside renderer folder -&gt;  components folder -&gt; permission.jsx</p>
<p dir="auto">and permission component use inside renderer folder -&gt; pages folder</p>
<p dir="auto">** I need camera, microphone and screen recording permission so I'm using systemPreferences But Getting undefined for system preference mediaType as a 'camera', 'microphone' and 'screen'**</p>
<p dir="auto"><em>Originally posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/dipaksavaliya04/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/dipaksavaliya04">@dipaksavaliya04</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1056094779" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/31875" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/31875/hovercard?comment_id=979751591&amp;comment_type=issue_comment" href="https://github.com/electron/electron/issues/31875#issuecomment-979751591">#31875 (comment)</a></em></p>
<h3 dir="auto">Preflight Checklist</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/main/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://www.github.com/electron/electron/issues">issue tracker</a> for a feature request that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Electron Version</h3>
<p dir="auto">15.0.0</p>
<h3 dir="auto">What operating system are you using?</h3>
<p dir="auto">macOS</p>
<h3 dir="auto">Operating System Version</h3>
<p dir="auto">macos catalina 1.01507</p>
<h3 dir="auto">What arch are you using?</h3>
<p dir="auto">Other (specify below)</p>
<h3 dir="auto">Last Known Working Electron version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">i should be able to run project successfully and want to remove this preference error</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">I'm creating a desktop application using electron. I need camera, microphone and screen recording permission so I'm using systemPreferences But Getting undefined for system preference mediaType as a 'camera', 'microphone' and 'screen'</p>
<h3 dir="auto">Testcase Gist URL</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional Information</h3>
<p dir="auto">Here is the full function we use to request media access. It is called when the Permission Request Handler is invoked with the media permission. The app does not reach the catch Block, so the error is not logged. We tested this behavior on 3 different machines</p>
<ul dir="auto">
<li>mediaType as a 'camera', 'microphone' and 'screen'</li>
</ul>
<p dir="auto"><strong>Below is a code</strong></p>
<p dir="auto">export default async function onPermission(mediaType) {<br>
try {<br>
console.log("systemPreferences", systemPreferences);<br>
const status = await systemPreferences.getMediaAccessStatus(mediaType);<br>
console.log(<code class="notranslate">Current ${mediaType}  access status:</code>, status);</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if (status === &quot;not-determined&quot;) {
  const success = await systemPreferences.askForMediaAccess(mediaType);
  console.log(
    `Result of ${mediaType}  access:`,
    success.valueOf() ? &quot;granted&quot; : &quot;denied&quot;
  );
  return success.valueOf();
}
return status === &quot;granted&quot;;"><pre class="notranslate"><code class="notranslate">if (status === "not-determined") {
  const success = await systemPreferences.askForMediaAccess(mediaType);
  console.log(
    `Result of ${mediaType}  access:`,
    success.valueOf() ? "granted" : "denied"
  );
  return success.valueOf();
}
return status === "granted";
</code></pre></div>
<p dir="auto">} catch (error) {<br>
console.log(<code class="notranslate">Could not get ${mediaType} permission:</code>, error.message);<br>
}<br>
return false;<br>
}</p>