Skip to content

fix(notify): register Windows AppUserModelID so toasts appear (#3)#4

Merged
karem505 merged 1 commit into
masterfrom
fix/windows-toast-aumid
Jun 6, 2026
Merged

fix(notify): register Windows AppUserModelID so toasts appear (#3)#4
karem505 merged 1 commit into
masterfrom
fix/windows-toast-aumid

Conversation

@karem505

@karem505 karem505 commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Fixes #3 — Windows 11 toast notifications never appear for the installed app.

Root cause

On an installed build, tauri-plugin-notification sets the toast's System.AppUserModel.ID to the bundle identifier (com.karem.whatrust) — see tauri-plugin-notification desktop.rs (notification.app_id(&self.identifier)), only on installed builds (in dev it uses the always-registered PowerShell AUMID, which is why notifications work under cargo run but 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:

  • the Desktop shortcut carries no AUMID property (only the Start-Menu one does),
  • a per-user vs per-machine install-path mismatch,
  • a regenerated/repaired shortcut that dropped the property,
  • or running the raw .exe.

When the AUMID isn't registered, CreateToastNotifierWithId/Show fails — and that error was swallowed at three layers (notify::show's let _ =, the notify command's unit return, and bridge.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):

  1. Write HKCU\Software\Classes\AppUserModelId\<identifier> with a DisplayName — 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.
  2. Call 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 to app_id()), so the two can't drift apart. The #[cfg(windows)] body compiles to a no-op on Linux/macOS.

Also: notify::show now logs the notification Result instead of discarding it, so any residual failure is diagnosable from the console.

Testing

  • cargo check/clippy/test --locked on Linux — pass (48 tests).
  • The exact #[cfg(windows)] module + the three new windows crate features (Win32_Security, Win32_System_Registry, Win32_UI_Shell) cross-compile clean for x86_64-pc-windows-gnu (verified in isolation) — CI's windows-latest job is the full gate.
  • Headless runtime boot: app starts, windows render, no panic in setup().
  • ⚠️ The toast actually rendering on Windows 11 needs confirmation on a real Win11 box (can't be exercised from Linux) — see the verification steps posted on Notification Doesn't Appear #3.

🤖 Generated with Claude Code

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 karem505 merged commit 74214a0 into master Jun 6, 2026
6 checks passed
@karem505 karem505 deleted the fix/windows-toast-aumid branch June 6, 2026 22:19
karem505 added a commit that referenced this pull request Jun 6, 2026
Ships the Windows AppUserModelID registration fix so toast notifications
appear for installed Windows builds (issue #3, PR #4).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification Doesn't Appear

1 participant