Skip to content

Commit

Permalink
fix: add entitlements info.plist with NSMicrophoneUsageDescription key (
Browse files Browse the repository at this point in the history
#97)

* fix: add entitlements info.plist with NSMicrophoneUsageDescription key

* Testing hardenedRuntime = true

* Disable hardenedRuntime

* fixed compilation

* request for media access

* update mediaType type

* increase version for release
  • Loading branch information
aixaCode authored Aug 22, 2022
1 parent 72bc95c commit 3058a1e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
15 changes: 14 additions & 1 deletion electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { shell, app, BrowserWindow, ipcMain, Tray, Menu, crashReporter } from 'electron'
import { shell, app, BrowserWindow, ipcMain, Tray, Menu, crashReporter, systemPreferences } from 'electron'
import * as isDev from 'electron-is-dev'
import { getOSName, getFreePort } from './updater'
import { exit } from 'process'
Expand Down Expand Up @@ -202,6 +202,10 @@ const startApp = async (): Promise<void> => {
await checkUpdates(win)
}

const microphoneResult = await askForMediaAccess('microphone');
if (!microphoneResult) {
console.log('Microphone permission was not given')
}
return Promise.resolve()
}

Expand Down Expand Up @@ -249,3 +253,12 @@ function initializeCrashReport() {

crashReporter.start({ uploadToServer: false })
}

const askForMediaAccess = async (mediaType: 'microphone' | 'camera') => {
if (systemPreferences.askForMediaAccess) {
// Electron currently only implements this on macOS
return await systemPreferences.askForMediaAccess(mediaType);
}
// For other platforms we can't reasonably do anything other than assume we have access.
return true;
}
16 changes: 16 additions & 0 deletions entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.device.microphone</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
</dict>
</plist>
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "explorer-desktop-launcher",
"version": "0.1.42",
"version": "0.1.43",
"author": "decentraland",
"description": "Decentraland Desktop Launcher",
"homepage": ".",
Expand Down Expand Up @@ -112,7 +112,12 @@
"target": [
"dmg",
"zip"
]
],
"hardenedRuntime": false,
"entitlements": "entitlements.mac.plist",
"extendInfo": {
"NSMicrophoneUsageDescription": "Need microphone access to use voice chat in the application"
}
},
"dmg": {
"icon": "public/installer-icon.icns",
Expand Down

0 comments on commit 3058a1e

Please sign in to comment.