Expand description
Native notifications, badge and sound policy.
Donor: CodeRight notifications.rs (per-target sound cooldown, navigate_path || title key,
non-negative badge, foreground attention cue, Do-Not-Disturb suppression through
crate::presence). The delivery itself is a direct OS call instead of a plugin:
UNUserNotificationCenter on macOS, which also gives the read-back used by QA
(delivered, authorization); a WinRT toast on Windows (the backend
tauri-plugin-notification uses). Other platforms report unsupported; nothing is faked.
Windows: a toast is attributed to an AppUserModelID (AUMID). An installed app owns one through
its Start-menu shortcut (Tauri’s NSIS/MSI installers set it to the bundle identifier); the
shell passes tauri.conf.json’s identifier as the default and set_app_id overrides it.
An unpackaged dev build has no AUMID, so toasts fall back to PowerShell’s and carry its
name and icon. Windows exposes neither a per-app permission prompt nor a delivered-toast
read-back through this backend: authorization reports authorized and delivered is
empty; clear_delivered is a no-op.
Notification settings that apps persist (sound on/off, sound name, per-category toggles — HeardRight and MailRight keep these in their own stores) arrive on every request; the shell owns the delivery policy, the app owns its preferences.
Structs§
- Delivered
Notification - One notification the OS reports as delivered to this app.
- Notification
Plan - Notification
Request - Notification
State - Notify
Outcome - What happened to a request.
- Notify
Status - Toast
Payload - Everything a Windows toast needs, built without touching the OS.
Constants§
- DEFAULT_
SOUND - macOS system sound used when the caller does not choose one.
- FALLBACK_
APP_ ID - Toast attribution used before an app registers its own: PowerShell’s AUMID (dev builds only).
- SOUND_
THROTTLE_ MS - Per-target notification-sound cooldown (CodeRight: Omnigent’s value).
Functions§
- app_id
- The AUMID toasts will use (configured, else
FALLBACK_APP_ID). - authorization
- clear_
delivered - delivered
- normalize_
badge - notification_
key - plan
- post
- Post a notification unless the request is empty or Do-Not-Disturb is in effect.
- resolve_
app_ id - set_
app_ id - Windows toast AppUserModelID. Call before the first notification; overrides the default the shell derives from the Tauri bundle identifier. Ignored off Windows.
- status
- suppression
- Why a request is not posted before reaching the platform (
empty-title,dnd), if it is not.bypass_do_not_disturbskips only the Do-Not-Disturb check. - toast_
payload - windows_
sound - Windows toast sounds by their short name; anything else (including macOS names such as
Glass) maps to the default toast sound.