electron-notify
electron-notify copied to clipboard
Windows 7
Hi,
I cannot get the notification to show up on windows 7. Can someone please advise?
Thank you
On Windows 7, if you are using a non-aero theme (ex Windows 7 Basic), transparency does not work. The notifications use transparency to round the corners, so you can't have rounded corners on Windows 7 if aero is turned off. If you don't care about that, then the easiest solution is to set defaultWindow.transparent to false, defaultWindow.backgroundColor to the same as defaultStyleContainer.backgroundColor, and defaultWindow.borderRadius to 0.
If you want to keep the rounded corners, you can have logic to check the value of "Composition" in the registry key \HKCU\Software\Microsoft\Windows\DWM. If it's 0x1, then you can do the transparency. Otherwise, you should show the square corners and not do transparency.
@kevinkir I just tried the above on Windows 7 (set defaultWindow.transparent to false, etc.) and I can get a notification window to display but none of the appIcon, title, or text are displaying. Any suggestions? Thanks!
@mz3io I had a Same problem. I think the reason is path of 'preload.js' in defaultWindow. Real config of defaultWindow is below.
defaultWindow: {
alwaysOnTop: true,
skipTaskbar: true,
resizable: false,
show: false,
frame: false,
transparent: true,
acceptFirstMouse: true,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
allowDisplayingInsecureContent: true
}
},
If I use
defaultWindow: {
alwaysOnTop: true,
skipTaskbar: true,
resizable: false,
show: false,
frame: false,
transparent: true,
acceptFirstMouse: true
}
in eNotify.setConfig()
,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
allowDisplayingInsecureContent: true
}
are gone. 'path' in this source is electron-notify's path, so I can't just write this code in my config.
I think we need a function to change transparent value of defaultWindow because config = _.defaults(customConfig, config)
can't handle this problem.
@dooyou21, my hacky workaround to this was to just to route the path through node_modules:
defaultWindow: {
alwaysOnTop: true,
skipTaskbar: true,
resizable: false,
show: false,
frame: false,
transparent: isTransparencySupported,
borderRadius: isTransparencySupported ? 5 : 0,
acceptFirstMouse: true,
backgroundColor: isTransparencySupported ? undefined : '#ffffff',
webPreferences: {
preload: path.join(__dirname, '..', 'node_modules', 'electron-notify', 'preload.js'),
allowDisplayingInsecureContent: true
}
}
Notes:
- The path to the
preload
script might be different, depending on your project setup. It might not be what you would expect it to be, either. Easiest way to figure it out is toconsole.log(__dirname)
, then figure out the path to node_modules based on that. -
isTransparencySupported
is determined based on the value of the "Composition" item in \HKCU\Software\Microsoft\Windows\DWM