Mac上Electron打包后无法弹出请求摄像头权限问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mac上Electron打包后无法弹出请求摄像头权限问题相关的知识,希望对你有一定的参考价值。

参考技术A 公司对接了某个产品,让我打包Mac上应用,发现了在未公证之前的包是可以弹出是否能访问摄像头的;但是公证之后,即打包之后是不能的,无法弹出询问是否能访问摄像头。
后来发现,需要再entitlements.mac.plist里,添加允许访问camera和麦克风的权限:

原因是因为:

In macOS 10.14 and later, the user must explicitly grant permission for each app to access cameras and microphones. Before your app can use the capture system for the first time, macOS shows an alert asking the user to grant your app access to the camera, as shown below. macOS remembers the user’s response to this alert, so subsequent uses of the capture system don’t cause it to appear again. The user can change permission settings for your app in System Preferences > Security & Privacy. The request for authorization looks different from the alert UI in ios.

详情请见:
https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos?language=objc

参见此文《Electron App 在 MacOS 下 申请摄像头及麦克风权限踩坑指南》
https://www.bugs.cc/p/electron-app-request-camera-and-microphone-permission-by-macos/

以上是关于Mac上Electron打包后无法弹出请求摄像头权限问题的主要内容,如果未能解决你的问题,请参考以下文章

Mac Electron App 签名后打开闪退

QT程序electron程序打包完毕之后,在MAC文件系统上的显示

electron打包后http请求为啥不存在跨域了

electron 打包mac的安装包没有菜单的问题解决

electron打包后请求static文件路径错误

用electron将Vue项目打包为window和Mac桌面应用 (electron-packager与electron-build)