Newbie electron question related to IPC


I want to achieve the following:

  1. have an index.html app on our server (I can create a electron specific index-electron.html if needed)
  2. use a package.json and main.js to create a mac and windows app
  3. My main.js on app.ready loads mainWindow.loadURL(< URL to index.html>)
  4. need to listen to events from my index.html on main.js, so I can update the AppIcon / badge.

I understand I can make calls from main.js to index.html using executeJavaScript(), but for receiving events the other way round, need to use IPC.

I am able to do the following:

  1. get IPC to work when both main.js and index.html are locally available
  2. get IPC to work if I have a remote wrapper index-wrapper.html, that loads the real index.html as an iframe. I keep node-integration as true

when I try to have the main index.html, which has its own jQuery etc, I get one of two problems:
A. if node-integration=false, I get error when initializing ipc: require is not defined
B. if node-integration=true, ReferenceError: jQuery is not defined, within my own app

Any suggestions or pointers to a samples with my setup will be greatly appreciated.




Your problem B sounds like this known issue:

You’ll basically have to do a require in your app. jQuery detects that module exists, and uses that instead of appending it to your window.