Projects / user-notify

user-notify

RustNative APIs

Why build yet another notification crate?

I built this during the DeltaTauri port. For a messenger, notifications need to do more than just show text - clicking a notification has to open the correct chat, not just the app window. You also need to programmatically remove notifications by ID (e.g. when a message is read on another device), show inline replies, and display action buttons.

Tauri's notification API at the time did not even support the basics like click handlers or removing notifications by ID. The existing Rust crates it used internally had the same gaps on some platforms. None of the alternatives covered all three operating systems with all the features that we needed.

Community interest

I initially built this as part of the DeltaTauri codebase and posted it as a workaround in the Tauri issue tracker. Community members asked me to extract it into its own crate so others could use it too.

Hey @Simon-Laux, I tried your crate on OSX and it works well thank you for sharing. Do you have any plan to extract it as a standalone crate?

Architecture

Each platform has its own implementation built from scratch:

Platform quirks

macOS was tricky: calling Objective-C APIs from async Rust with main-thread requirements led to quite a few crashes early on, but we ironed out the quirks and it now works really well.

Linux is still the most challenging. Different desktop environments, the split between the classic D-Bus API and the Flatpak portal API, and my limited understanding of D-Bus internals mean there are still bugs to fix, and that's a work in progress.

Windows had its own challenges: the documentation can be hard to follow without prior experience with Windows APIs. But each platform is rewarding when it finally works. The whole point is to make it easier for others to do good notifications from Rust without thinking about these platform details and maintaining three different implementations.

Usage in Delta Chat

Delta Chat Desktop (Tauri edition) uses user-notify for all its notifications: message previews with image attachments, group and contact avatars, and the reply-from-notification feature on macOS.

The same feature would be possible on Windows, but hasn't been enabled yet due to open questions around security1. Persistent notifications also work correctly: clicking one after the app has been closed reopens it at the right place.

Status

macOS and Windows work well. Linux still has some bugs (see the issue tracker for details). I plan to maintain this further, and that's another reason I extracted it into its own repo. The DeltaTauri edition is still experimental, so there isn't heavy production pressure yet, but the library is solid on macOS and Windows.

If you need a specific feature or want to sponsor development, feel free to reach out: git@simonlaux.de.


  1. On Windows, notification reply actions work via custom URI deeplinks. When the app isn't running, a browser or other program could craft a link that fakes the reply URI and triggers sending a message. We disabled it in Delta Chat until we find a solution. See deltachat-desktop#5134.