电子应用不要求在Macos Monterey上获得相机和麦克风许可
我已经建立了堆栈电子和ReactJ的应用。我正在尝试从应用程序访问相机和麦克风。但是,该应用在要求时不要求许可,也不会在系统首选项中显示-GT;相机和麦克风下的安全性和隐私。 以下是我使用的版本:
"electron": "^15.3.0",
"electron-builder": "^22.14.5",
"electron-devtools-installer": "^3.2.0",
"electron-notarize": "^1.1.1",
"electron-rebuild": "^3.2.3",
"react": "^17.0.2"
让我知道我缺少什么或需要更改。提前致谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也遇到了这个问题,它在Macos Catalina效果很好,但在蒙特雷,有时效果很好。
我在电子官方文档中阅读了此信息后解决了:
“如果您打算使用Electron的API访问应用程序中的麦克风或相机,则还需要添加以下权利”
来添加授权,因为您正在使用
> code>电子构建器
有一个可以在package.json
中使用的配置,将其添加到“ mac”
下,您需要添加此:然后您需要添加以下几行要求媒体权限:
I also had this problem it worked fine in macOS Catalina but in Monterey sometimes it didn't.
I solved after reading this in the electron official documentation:
"If you plan to access the microphone or camera within your app using Electron's APIs, you'll also need to add the following entitlements"
To add the entitlements since you are using
electron-builder
there's a config that you can use inpackage.json
to add it under"mac"
you add this:And then you need to add the following lines to ask for media permissions:
我想在
所以我找到了以下修复程序。在
mac
配置下,请添加以下属性为false
I would like to add extra information with the answer of Caio Nakai
I'm having application crash issue with this fix also.
So I found the following fix. Under
mac
configuration please add the following property asfalse
和平与善良!这对我有帮助:
systempreferences.askeformediaaccess('麦克风')
SystemPreferences.askformediaAccess('Camera'),
但仅使用
https:> https://www.electron.build/configuration/ mas
wittlements string | “未定义” - 签署应用程序的权利文件的路径。如果存在,将使用build/with.mas.mas.plist(这是推荐的设置方法)。有关示例,请参见OSX-Sign存储库中的此文件夹。 请注意,如果不像com.apple.security.cs.c.s.ally-jit设置正确的权利,则您的应用程序可能会崩溃电子文档以获取更多信息。
Peace and Kindness! This helped me:
systemPreferences.askForMediaAccess('microphone')
systemPreferences.askForMediaAccess('camera')
but only with it
https://www.electron.build/configuration/mas
https://github.com/electron/osx-sign/blob/main/entitlements/default.darwin.plist
entitlements String | “undefined” - The path to entitlements file for signing the app. build/entitlements.mas.plist will be used if exists (it is a recommended way to set). See this folder in osx-sign’s repository for examples. Be aware that your app may crash if the right entitlements are not set like com.apple.security.cs.allow-jit for example on arm64 builds with Electron 20+. See Signing and Notarizing macOS Builds from the Electron documentation for more information.