https://github.com/tauri-apps/winrt-notification
An incomplete wrapper over the WinRT toast api written in rust
https://github.com/tauri-apps/winrt-notification
Last synced: 2 months ago
JSON representation
An incomplete wrapper over the WinRT toast api written in rust
- Host: GitHub
- URL: https://github.com/tauri-apps/winrt-notification
- Owner: tauri-apps
- License: apache-2.0
- Fork: true (allenbenz/winrt-notification)
- Created: 2022-08-13T20:52:20.000Z (over 3 years ago)
- Default Branch: dev
- Last Pushed: 2024-10-29T14:23:41.000Z (about 1 year ago)
- Last Synced: 2025-01-15T00:28:21.677Z (11 months ago)
- Language: Rust
- Homepage:
- Size: 137 KB
- Stars: 15
- Watchers: 4
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.spdx
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# winrt-notification
[](https://crates.io/crates/tauri-winrt-notification/)
[](https://docs.rs/tauri-winrt-notification)
An incomplete wrapper over the WinRT toast api
Tested in Windows 10 and 8.1. Untested in Windows 8, might work.
Todo:
* Add support for Adaptive Content
Known Issues:
* Will not work for Windows 7.
Limitations:
* Windows 8.1 only supports a single image, the last image (icon, hero, image) will be the one on the toast
## Usage
```toml
#Cargo.toml
[dependencies]
tauri-winrt-notification = "0.5.1"
```
## Examples
```rust
extern crate winrt_notification;
use tauri_winrt_notification::{Duration, Sound, Toast};
fn main() {
Toast::new(Toast::POWERSHELL_APP_ID)
.title("Look at this flip!")
.text1("(╯°□°)╯︵ ┻━┻")
.sound(Some(Sound::SMS))
.duration(Duration::Short)
.show()
.expect("unable to toast");
}
```
```rust
extern crate winrt_notification;
use std::path::Path;
use tauri_winrt_notification::{IconCrop, Toast};
fn main() {
Toast::new("Your AppUserModeId")
.hero(&Path::new("C:\\absolute\\path\\to\\image.jpeg"), "alt text")
.icon(
&Path::new("c:/this/style/works/too/image.png"),
IconCrop::Circular,
"alt text",
)
.title("Lots of pictures here")
.text1("One above the text as the hero")
.text2("One to the left as an icon, and several below")
.image(&Path::new("c:/photos/sun.png"), "the sun")
.image(&Path::new("c:/photos/moon.png"), "the moon")
.sound(None) // will be silent
.show()
.expect("unable to toast");
}
```