fix(notify): register Windows AppUserModelID so toasts appear (#3)#4
Merged
Conversation
On installed Windows builds, tauri-plugin-notification sets the toast's System.AppUserModel.ID to the bundle identifier (com.karem.whatrust). A WinRT toast only renders if that AUMID is registered on the system; when the registration isn't effective at toast-time — the Desktop shortcut carries no AUMID, a per-user vs per-machine path mismatch, a regenerated shortcut that dropped the property, or a raw-exe run — CreateToastNotifier /Show fails, and that error was swallowed at three layers (notify.rs, the command, and bridge.js). The result: no toast and nothing logged, exactly the "payload never reaches Action Center, no drop logs" symptom in #3. Register the AUMID at startup under HKCU\Software\Classes\AppUserModelId\ <id> (DisplayName) and call SetCurrentProcessExplicitAppUserModelID, both Windows-only, per-user (no admin), and idempotent — so toasts render regardless of installer (NSIS/MSI) or launch path, and a shortcut that lost its AUMID self-heals on next launch. The AUMID is read from the live Tauri config identifier, the same value the plugin passes to app_id(), so the two can't drift. Also stop discarding the Result in notify::show and log it instead, so any residual toast failure is diagnosable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
karem505
added a commit
that referenced
this pull request
Jun 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3 — Windows 11 toast notifications never appear for the installed app.
Root cause
On an installed build,
tauri-plugin-notificationsets the toast'sSystem.AppUserModel.IDto the bundle identifier (com.karem.whatrust) — seetauri-plugin-notificationdesktop.rs(notification.app_id(&self.identifier)), only on installed builds (in dev it uses the always-registered PowerShell AUMID, which is why notifications work undercargo runbut break once installed).A WinRT toast only renders if that AUMID is registered on the system. Tauri's NSIS/MSI installers do tag their Start-Menu shortcut with the AUMID, but that registration is fragile and can be ineffective at toast-time:
.exe.When the AUMID isn't registered,
CreateToastNotifierWithId/Showfails — and that error was swallowed at three layers (notify::show'slet _ =, thenotifycommand's unit return, andbridge.js's empty.catch()). Net effect: no toast and nothing logged — exactly the reporter's "payload never reaches Action Center, no drop logs" symptom.Fix
At startup (
aumid::register, Windows-only, per-user, no admin, idempotent):HKCU\Software\Classes\AppUserModelId\<identifier>with aDisplayName— this registers the AUMID so the Action Center renders toasts for an unpackaged desktop app, independent of installer or launch path. Re-written each launch, so a shortcut that lost its AUMID self-heals.SetCurrentProcessExplicitAppUserModelID(<identifier>)to pin the process to the same AUMID.The AUMID is read from the live Tauri config
identifier(the same value the plugin passes toapp_id()), so the two can't drift apart. The#[cfg(windows)]body compiles to a no-op on Linux/macOS.Also:
notify::shownow logs the notificationResultinstead of discarding it, so any residual failure is diagnosable from the console.Testing
cargo check/clippy/test --lockedon Linux — pass (48 tests).#[cfg(windows)]module + the three newwindowscrate features (Win32_Security,Win32_System_Registry,Win32_UI_Shell) cross-compile clean forx86_64-pc-windows-gnu(verified in isolation) — CI'swindows-latestjob is the full gate.setup().🤖 Generated with Claude Code