use mac_usernotifications::{Action, Notification, blocking};
use std::time::Duration;
mod common;
fn main() {
if !common::setup(file!()) {
return;
}
let worker = std::thread::spawn(|| {
let notification = Notification::new()
.title("Pitfall demo")
.message("Main run loop is not being pumped — watch the warning above.")
.action(Action::button("ok", "OK"))
.timeout(Duration::from_secs(8));
let response = blocking::send_with_actions(notification);
match response {
Ok(resp) if resp.is_timed_out() => {
log::warn!("timed out — as expected, the callback never arrived");
}
Ok(resp) => {
log::info!("got response: {:?}", resp.action_identifier);
}
Err(err) => log::error!("error: {err}"),
}
});
worker.join().expect("worker thread panicked");
log::info!("done");
}