Nothing happens on appWindow.webContents.send()


#1

I can use IPC from the render process to the main process.

Now I try to send from the main to the appWindow.

appWindow.webContents.send('info' , {msg:'hello from main process'});

in the appwindow render.js

var ipcR = electron.ipcRenderer;
ipcR.on('info' , function(event , data){
  console.log(data.msg)
  udpinputtext ='got Message';
});

nothing happes, there’s no error in the log! all other things, like react stuff, is working.


#2

Is render.js running in a sandboxed window? If so, then bear in mind that the event will not be passed to sandboxed code and so the callback becomes function(data) instead of function(event, data).

If your window is not sandboxed then you’ll receive both parameters.

I wonder if you are trying to interact with the window before the new process has had time to establish itself. I usually wait for the window to be ready by using window.once('ready-to-show', function(){});.

Also, you haven’t mentioned whether this script is in the HTML or being preloaded.