h4llow3En / mac-notification-sys

✉️ A simple wrapper to deliver or schedule macOS Notifications in Rust
98 stars 28 forks source link

Updating to objc2 and adding async support #56

Open dscso opened 4 months ago

dscso commented 4 months ago

I have been writing a version of this crate but with interaction support based on the NSUserNotification Library. Here is a working example: https://github.com/dscso/mac-notifications

let mut provider = NotificationProvider::new("Terminal");

// callback for notification interaction
provider.set_callback(|id, resp| {
   println!("Notification {} clicked: {:?}", id, resp);
});

// sends notification
Notification::new()
    .title("Hello")
    .reply(true)
    .send().unwrap();

// run the main loop. If some notification gets interacted with, the callback will be called
for _ in 0..50 {
    provider.run_main_loop_once();
}

I've improved

What has to be done:

Maybe this could be combined with #51 to create a full 2.0?

hoodie commented 4 months ago

Sounds awesome! Thanks

dscso commented 4 months ago

For the integration of the UNNotification version I don't have a key to sign applications and therefore test it. So I can't help with this. But I can work on a PR for the NSNotificaiton

hoodie commented 4 months ago

just for reference: my friend @payload did a tiny example using a self-signed key that should be good enough for local testing https://github.com/payload/tiny-usernotifications-example