Skip to main content

notification/
notification.rs

1const APP_ID: &str = "rustydialogs.example.notify";
2
3fn main() {
4	// winrt-toast: Takes almost three seconds to show the first notification due to registration delays.
5	// All Notifications shown before the registration is complete will be ignored.
6	rustydialogs::Notification::setup(APP_ID);
7
8	let i = std::process::id() / 4;
9
10	let icon = match i % 4 {
11		0 => rustydialogs::MessageIcon::Info,
12		1 => rustydialogs::MessageIcon::Warning,
13		2 => rustydialogs::MessageIcon::Error,
14		_ => rustydialogs::MessageIcon::Question,
15	};
16
17	let notify = rustydialogs::Notification {
18		app_id: APP_ID,
19		title: "Rusty Dialogs",
20		message: "This is a native notification.",
21		icon,
22		timeout: rustydialogs::Notification::SHORT_TIMEOUT,
23	};
24
25	notify.show();
26	println!("Notification shown");
27
28	// winrt-toast: Wait a bit to ensure the notification is visible before the program exits.
29	std::thread::sleep(std::time::Duration::from_millis(100));
30}