Skip to content

Instantly share code, notes, and snippets.

@mnquintana
Created Jan 29, 2018
Embed
What would you like to do?
Path 2: Remote Isolation
// ==============
// Main process
// ==============
const {BrowserWindow} = require('electron');
const mainWindow = new BrowserWindow({
width: 800,
height: 800,
webPreferences: {
preload: './path/to/preload/script.js',
nodeIntegration: false,
contextIsolation: true,
// ...
}
});
mainWindow.loadURL('https://<remote-web-app-goes-here>');
// ==============
// Preload script
// ==============
const {remote} = require('electron');
window.interop = {
setBadgeCount(count) {
return remote.app.setBadgeCount(count);
}
};
// ==============
// Guest page (remote web app)
// ==============
if (window.interop) window.interop.setBadgeCount(9001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment