setDevicePermissionHandler
Sets the handler which can be used to respond to device permission checks for the session
. Returning true
will allow the device to be permitted and false
will reject it. To clear the handler, call setDevicePermissionHandler(null)
. This handler can be used to provide default permissioning to devices without first calling for permission to devices (eg via navigator.hid.requestDevice
). If this handler is not defined, the default device permissions as granted through device selection (eg via navigator.hid.requestDevice
) will be used. Additionally, the default behavior of Electron is to store granted device permission in memory. If longer term storage is needed, a developer can store granted device permissions (eg when handling the select-hid-device
event) and then read from that storage with setDevicePermissionHandler
.