| Crates.io | universal_notifications |
| lib.rs | universal_notifications |
| version | 0.1.7 |
| created_at | 2025-10-03 10:32:55.796242+00 |
| updated_at | 2025-11-10 21:16:56.356522+00 |
| description | Wrapper for WINRT toast api and UserNotifications |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1866507 |
| size | 257,309 |
An incomplete wrapper for WinRT Toast and MacOS UserNotifications
Known Issues:
//Cargo.toml
[dependencies]
universal_notifications = "0.1.1"
// Or if you want only some features
[dependencies]
universal_notifications = { version = "0.1.1", features = ["windows"]}
Note: All Windows-specific examples require the
windowsfeature and must be run on Windows 10/11.
use universal_notifications::Toast;
use universal_notifications::Duration;
fn main() -> windows::core::Result<()> {
Toast::new(Toast::APP_ID)
.title("Hello, World!")
.description("This is a simple toast notification.")
.duration(Duration::Short)
.show()?;
Ok(())
}
use std::path::Path;
use universal_notifications::{Toast, Duration, IconCrop};
fn main() -> windows::core::Result<()> {
let icon_path = Path::new(r"C:\path\to\icon.png");
let image_path = Path::new(r"C:\path\to\image.jpg");
Toast::new(Toast::APP_ID)
.title("Picture Toast")
.description("This toast has an icon and an image.")
.icon(icon_path, IconCrop::Circular, "App icon")
.image(image_path, "Main image")
.duration(Duration::Long)
.show()?;
Ok(())
}
use universal_notifications::{Toast, Duration, ActivationType, Sound, LoopableSound};
fn main() -> windows::core::Result<()> {
Toast::new(Toast::APP_ID)
.title("Action Toast")
.description("You can interact with this notification.")
.action("Open App", "open", ActivationType::Foreground)
.action("Dismiss", "dismiss", ActivationType::Background)
.sound(Some(Sound::Loop(LoopableSound::Alarm)))
.duration(Duration::Long)
.show()?;
Ok(())
}
use universal_notifications::{Toast, Duration};
fn main() -> windows::core::Result<()> {
Toast::new(Toast::APP_ID)
.title("Silent Notification")
.description("No sound will play for this one.")
.sound(None)
.duration(Duration::Short)
.show()?;
Ok(())
}