From 9757059dfc2fe8d7c9f66af8ab9a1cee9748e7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20C=C3=B4t=C3=A9?= Date: Thu, 14 Sep 2023 17:44:21 -0400 Subject: [PATCH] Handle request and check permissions --- examples/electron/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/electron/README.md b/examples/electron/README.md index 58907af05..26ee73a87 100644 --- a/examples/electron/README.md +++ b/examples/electron/README.md @@ -5,3 +5,25 @@ A collection of examples to use WEBMIDI.js inside an Electron application. ## Examples * [**Basic Electron Example**](basic-example) + +## Platform specific notes + +The permission requests must be properly handled in the main process before initializing WEBMIDI: + +```javascript + mainWindow.webContents.session.setPermissionRequestHandler((webContents, permission, callback, details) => { + if (permission === 'midi' || permission === 'midiSysex') { + callback(true); + } else { + callback(false); + } + }) + + mainWindow.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin) => { + if (permission === 'midi' || permission === 'midiSysex') { + return true; + } + + return false; + }); +```