Search code examples
macoselectrondesktop-applicationelectron-builder

Notification from electron shows electron.app.Electron


I am developing an electron + ionic application and using electron notifications. I have packaged the application using electron builder and installed it on my PC. The notification comes with the text 'electron.app.Electron' instead of the app name from the package. This is the sample notification code:

 click: function() {
      const notification = {
        title: 'Basic Notification',
        body: 'Notification from the Main process',
        icon:path.join(__dirname, 'favicon.ico'),
        silent : false
      }
      new Notification(notification).show()
    }

How can I get the notification to display the app name instead of electron.app.Electron? When I used the tray displayBalloon option instead, it displayed the name correctly but unfortunately, it's not supported in Mac and I had to shift to using electron notification.


Solution

  • Please have a look at these two answers to more or less the same question:

    Basically, you need to call app.setAppUserModelId() on Windows:

    if (process.platform === 'win32')
    {
        app.setAppUserModelId(app.name);
    }