webContents.send And ipcRenderer.on


#1

I am making an electron application and I am trying to use ipcRenderer to communicate between my window.html file to my main.js script, the problem is that the HTML file doesn’t get the message I am sending using webContents.send.

this is my main.js script:
mainWindow.webContents.send("command:message" , whatToLog);

this is my window.html script:

ipcRenderer.on('command:message', function(e, whatToLog) { console.log(whatToLog); });

the problem is that it doesn’t get the message, any help?


#2

you must sure that
ipcRender.on is set before webContents.send()


#3

The ipcRenderer is set before that.


#4

can you put all of ur code here, or maybe try something like change channel name