# Universal Notifications
An incomplete wrapper for WinRT Toast and MacOS UserNotifications
Known Issues:
* Only works on Windows 10 and 11.
## Usage
```rust
//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 `windows` feature and must be run on Windows 10/11.
## Examples
### Simple Toast
```rust
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(())
}
```
### Toast with Images and Icons
```rust
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(())
}
```
### Toast with Actions and Sound
```rust
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(())
}
```
### Silent Toast
```rust
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(())
}
```