windows-installer
windows-installer copied to clipboard
3.0.4 breaks notification.onclick. Working on 2.7.0, full reproduction
- Electron Version:
- 4.0.8
- windows-installer Version:
- 3.0.4
- Last Known Working windows-installer version:
- 2.7.0
Expected Behavior
The following code should produce a notification and when clicked present an alert
const n = new Notification(1)
n.onclick = function () { alert('click') }
Actual Behavior
Works as expected when using 2.7.0, in 3.0.4 the notification presents, but the click event is never fired
To Reproduce
The following repo has a Notification example and takes care of creating a installer, start menu shortcuts etc. It basically a merge of electron-quick-start and the Handling Squirrel Events section in README
git clone https://github.com/wavebox/electron-quick-start.git -b winstaller-304-shortcut
cd electron-quick-start
npm install
npm run installer
Run the generated installer under electron-quick-start-installer. The app will present a notification and when clicked does nothing.
The same example works with 2.7.0. To try this...
- Manually uninstall
electron-quick-start(this is important) - Downgrade
electron-winstallerto2.7.0 npm run installer- Install and try again
Additional Information
I've been digging around what's going on here, and it's definately down to the start menu shortcut that gets generated in 3.0.4. Install with 3.0.4 and replace the shortcut with the 2.7.0 version and it works!
Using lnk-parser the only discernable difference that I can find is the value type is different for System.AppUserModel.ID. Here's the entry for both...
2.7.0
- Property set GUID 9f4c2855-9f79-4b39-a8d0-e1d42de1d5f3
- ID 26
- Value 0x001f (VT_LPWSTR)
- b2b6457d-4173-5767-b785-be9d6904b546
- ID System.AppUserModel.ID
- Value 0x001f (VT_LPWSTR)
- com.squirrel.electron-quick-start.electron-quick-start
3.0.4
- Property set GUID 9f4c2855-9f79-4b39-a8d0-e1d42de1d5f3
- ID 26
- Value 0x0048 (VT_CLSID)
- CLSID:b2b6457d-4173-5767-b785-be9d6904b546
- ID System.AppUserModel.ID
Value 0x001f (VT_LPWSTR)
- com.squirrel.electron-quick-start.electron-quick-start
I could be off the mark here, it could be something different. If you need any more info let me know!
same issue here. 4.0 still has this bug. 'click' event works on DEV mode, but not work on RELEASE mode.
i'm able to make a workaround : create shortcuts and setAppUserModelId manually
let WindowsShortcuts = require('windows-shortcuts');
WindowsShortcuts.create('%APPDATA%/Microsoft/Windows/Start Menu/Programs/myapp.lnk', process.execPath);
app.setAppUserModelId(process.execPath);
same issue here. 4.0 still has this bug. 'click' event works on DEV mode, but not work on RELEASE mode.
I met this issue also.
I also experienced this issue, 2.7.0 working fine
I also encountered this bug, but only on Windows 10, on Windows 8 the event is emitted. The latest version that works is 2.7.0. Unfortunately, 2.7.0 is affected by this bug.
Original: https://github.com/electron/windows-installer/issues/296#issuecomment-542586319
Solution but not recommended:
make appUserModelID not match to id from Squirrel. For example, if appUserModelID of your app set by squirrel is 'com.squirrel.slack.slack', then use app.setAppUserModelId to make id as something different, like 'com.squirrel.slack.slack.com'. This make notification clickable with electron-winstaller@latest.
But this solution change app name on notification like 'Slack' to 'com.squirrel.slack.slack.com'. And also it makes your app not to respect windows notification settings. so be careful.
This issue is still not resolved? This is a pretty critical issue for any modern desktop application.
Is there any update on resolving this issue for Wire desktop?
This is still not resolved with 4.0.1 and 5.0.0.
i'm able to make a workaround : create shortcuts and setAppUserModelId manually
let WindowsShortcuts = require('windows-shortcuts'); WindowsShortcuts.create('%APPDATA%/Microsoft/Windows/Start Menu/Programs/myapp.lnk', process.execPath); app.setAppUserModelId(process.execPath);
Thanks @roytan883 - this helped me! This is how I fixed it: https://github.com/wireapp/wire-desktop/pull/4965
Update: It seems like clicking the first notification opens the app, but if there are two notifications clicking the second notification won't open the app :thinking:
fwiw, I'm using electron-forge with squirrel installers (@electron-forge/maker-squirrel:6.0.0-beta.54) and only needed to set app.setAppUserModelId
src/index.ts
if(process.platform === "win32") {
app.setAppUserModelId(process.execPath)
}
app.on('ready', () => {
...
});
`
This is still not resolved with 4.0.1 and 5.0.0.
i'm able to make a workaround : create shortcuts and setAppUserModelId manually
let WindowsShortcuts = require('windows-shortcuts'); WindowsShortcuts.create('%APPDATA%/Microsoft/Windows/Start Menu/Programs/myapp.lnk', process.execPath); app.setAppUserModelId(process.execPath);Thanks @roytan883 - this helped me! This is how I fixed it: wireapp/wire-desktop#4965
Update: It seems like clicking the first notification opens the app, but if there are two notifications clicking the second notification won't open the app 🤔
Thanks so much for the example in the wire-desktop soucre @ffflorian. This helped me fix a long running issue with windows toast click events. I can't believe this still isn't fixed in electron-winstaller.
fwiw, I'm using electron-forge with squirrel installers (@electron-forge/maker-squirrel:6.0.0-beta.54) and only needed to set app.setAppUserModelId
src/index.tsif(process.platform === "win32") { app.setAppUserModelId(process.execPath) } app.on('ready', () => { ... }); `
Be careful @ainesophaur, while this fixes the click events it also makes every notification appear with the absolute path of the exe in the title:

The best solution can be found in @ffflorian's example.
Note to anyone reading -- I spent hours trying to get toasts in Action Center to emit events with no luck. I stumbled across this stackoverflow thread which describes how you need to register a COM server in order to support that functionality. Apparently this module supports that, but I've not tested it.
I even went so far down the rabbit hole trying to get this to work before I found that stackoverflow thread that I ported the createGuidFromHash functionality from Squirrel.Windows to javascript in an attempt to comply with the standards defined for ToastActivatorCLSID. Maybe some day someone will find a use for this.