Skip to main content

Module notify

Module notify 

Source
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§

DeliveredNotification
One notification the OS reports as delivered to this app.
NotificationPlan
NotificationRequest
NotificationState
NotifyOutcome
What happened to a request.
NotifyStatus
ToastPayload
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_disturb skips 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.