Skip to content

Instantly share code, notes, and snippets.

@mnquintana
Created January 29, 2018 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnquintana/c3cee24efc7dd20ebda8f69944b2fdfc to your computer and use it in GitHub Desktop.
Save mnquintana/c3cee24efc7dd20ebda8f69944b2fdfc to your computer and use it in GitHub Desktop.
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