Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to objc2 and adding async support #56

Open
dscso opened this issue Apr 28, 2024 · 3 comments
Open

Updating to objc2 and adding async support #56

dscso opened this issue Apr 28, 2024 · 3 comments

Comments

@dscso
Copy link

dscso commented Apr 28, 2024

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

  • memory leaks (now there should be none)
  • expose delegate (user of the library can set a new delegate)
  • give control over main_loop (like in Version 2 #51)
  • moved to obj2 since it provides a much more stable/easy to use API
  • moved most of the stuff I could form the .m file to Rust 🦀

What has to be done:

  • action buttons not working yet
  • testing for bugs/memory bugs

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

@hoodie
Copy link
Collaborator

hoodie commented Apr 29, 2024

Sounds awesome! Thanks

@dscso
Copy link
Author

dscso commented Apr 30, 2024

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
Copy link
Collaborator

hoodie commented Apr 30, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants