#notification #windows #notify #toast

winrt-notification

An incomplete wrapper over the WinRT toast api

11 releases

0.3.0 Feb 16, 2021
0.2.4 Feb 21, 2021
0.2.2 Feb 8, 2018
0.2.0 Jan 8, 2018
0.1.4 Sep 24, 2017

#15 in Windows APIs

Download history 1096/week @ 2020-11-10 1010/week @ 2020-11-17 953/week @ 2020-11-24 1059/week @ 2020-12-01 1246/week @ 2020-12-08 905/week @ 2020-12-15 906/week @ 2020-12-22 1043/week @ 2020-12-29 1595/week @ 2021-01-05 1316/week @ 2021-01-12 1301/week @ 2021-01-19 1510/week @ 2021-01-26 1296/week @ 2021-02-02 1575/week @ 2021-02-09 1832/week @ 2021-02-16 1364/week @ 2021-02-23

5,291 downloads per month
Used in 28 crates (2 directly)

MIT license

33KB
293 lines

winrt-notification

license version Build Status

An incomplete wrapper over the WinRT toast api

Tested in Windows 10 and 8.1. Untested in Windows 8, might work.

Documentation

Todo:

  • Add support for Adaptive Content
  • Add support for Actions
  • A method of generating a valid app id

Known Issues:

  • Will not work for Windows 7.
  • Will not build when targeting the 32-bit gnu toolchain (i686-pc-windows-gnu).

Limitations:

  • Windows 8.1 only supports a single image, the last image (icon, hero, image) will be the one on the toast

Usage

#Cargo.toml
[dependencies]
winrt-notification = "0.2.2"

Examples

extern crate winrt_notification;
use 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");
}
extern crate winrt_notification;
use std::path::Path;
use 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");
}

Dependencies

~13MB
~41K SLoC