electron: tray displayBalloon does not work well
- Electron version: after 1.1.2
- Operating system: Windows
It works well up to version 1.1.1.
Since version 1.1.2 displayBalloon does not work well. Especially when multiple asynchronous operations are made at the same time displayBalloon often ignored.
setInterval(function(){
tray.displayBalloon({
title:'hello',
content:'world'
});
},3000);
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 22 (9 by maintainers)
Commits related to this issue
- Use the PNG file instead of ICO for the system tray icon. Apparently there is some weirdness/bugs with using .ico files in electron, so we should be using the pngs from now on. See this issue: https... — committed to ShieldBattery/ShieldBattery by 2Pacalypse- 7 years ago
- Use the PNG file instead of ICO for the system tray icon. (#267) Apparently there is some weirdness/bugs with using .ico files in electron, so we should be using the pngs from now on. See this is... — committed to ShieldBattery/ShieldBattery by 2Pacalypse- 7 years ago
Given that there exist workarounds for this, and that this isn’t currently on our roadmap, i’m going to go ahead and label this a
wontfix. However, should someone determine a workable solution we would be very open to accepting a PR!Same to me.
I added icon in
displayBalloonas @insideGen said and it works. Without icon, tray message cannot be displayed.The following code works correctly: when a click event is detected, the balloon appears.
The following code works incorrectly: when an update event is detected,
log.info()works butappTray.displayBalloon()doesn’t.If I add the
iconproperty inside the balloon object, it’s work fine. But the icon needs to be a .png format, not .ico.I’m on electron 1.8.1 and tray balloon doesnt work from async calls. tried setting the icon to png/ico but no balloon.
I can confirm that this still does not function when a .ico file is used for the icon. If I omit that, the balloon works and actually uses the application’s icon, albeit a horrendously pixelated version of it. Using Windows 10.
For me changing my .ico files to .png did not work, however, calling setImage immediately before displayBalloon does…
Update: I take it back - that only worked once so it is probably unrelated…
Confirmed this in Electron 1.3.5 and Windows 10 64-bit ver 1607. Setting the tray icon to an .ico renders the app unable to display notifications, while setting it to a .png renders the first notification unable to display until a second one is received.
I made the mistake of setting my app icon a .png file while consequent displayBalloons calls were using an .ico file. Setting them all to use .png fixed notifications for me.
appIcon = new Tray(__dirname + '/images/icon.png');appIcon.displayBalloon({ icon: __dirname + '/images/icon.png', title: data.title, content: data.message, });If it’s any help, I initialized my Tray instance during the app ready event, and displayed tray balloons when an event from my renderer process was received by ipcMain.
A thing to note is that even as the balloon icon was set, somehow notifications aren’t consistently provided an icon:
I tested this module and seems works well
https://github.com/hankbao/electron-notify
so for these who want to upgrade to the latest electron version, you may use this instead of displayBalloon
Hmm I don’t know why but I can not reproduce this on either Windows 10 or 8.1.