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

Notification Listeners for Mac and Windows #186

Open
cheeseblubber opened this issue Jun 20, 2023 · 17 comments
Open

Notification Listeners for Mac and Windows #186

cheeseblubber opened this issue Jun 20, 2023 · 17 comments

Comments

@cheeseblubber
Copy link

Problem

We are building a Slack/Discord like chat client (linen.dev) with Tauri. The problem is we don't have any notification listeners for Mac and windows so that we know which notification they click on so we can show the proper channel/thread.

Describe the solution you'd like

According to this windows and mac listeners are not implemented
https://docs.rs/notify-rust/latest/notify_rust/#notificationhandle

Additional context

tauri-apps/plugins-workspace#2150

For mac we ran into issue with https://github.com/h4llow3En/mac-notification-sys because was blocking which spiked cpu usage to 100% when we received a notification and it would stay at 100% until we closed the notification.

@algora-pbc
Copy link

💎 $300 bounty created by @cheeseblubber
👉 To claim this bounty, submit your pull request on Algora
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to hoodie/notify-rust!

@hoodie
Copy link
Owner

hoodie commented Jun 20, 2023

Full Disclaimer: this library can only do what the underlying operating-system primitives actually provide.

@hoodie
Copy link
Owner

hoodie commented Jun 20, 2023

@cheeseblubber can you show what you were doing that cause the 100% CPU usage on macOS? AFAIK the sending should not block already.

@sandrodesouza
Copy link

hi @hoodie, this is what we were doing https://github.com/Linen-dev/linen.dev/blob/51406feb8f27c95081d36f4ee2cc9139caec25c0/packages/spa/src-tauri/src/notifications.rs#L29 with was with the mac_notification_sys lib not notify-rust.

CPU went to 100% until we dismiss the notification. This is how we call the function https://github.com/Linen-dev/linen.dev/blob/51406feb8f27c95081d36f4ee2cc9139caec25c0/packages/spa/src-tauri/src/main.rs#L75

This was the only workaround we find to know in which notification the user clicked.

@tyush
Copy link

tyush commented Jun 22, 2023

Windows implementation blocked on this pull request to tauri-winrt-notification, a dependency of notify-rust.

@whizsid
Copy link

whizsid commented Jul 11, 2023

/attempt tauri-apps/tauri#186 . only macOS.

@whizsid
Copy link

whizsid commented Jul 12, 2023

mac-notification-sys is using the old foundation user notifications API which deprecated. Updating this crate is a huge change and breaking the BC. So I decided to write a crate by my own using the new User Notifications framework. I hope to manage notifications using a Stream like api. Currently the mac-notification-sys is using a loop to listen for notification changes.

Also the new notification framework is only supporting action buttons for notification categories. But I think we can internally manage those categories without changing the existing API of notify-rust.

UPDATE:- Updating to the new notification framework was already in the TO DO list of mac-notification-sys. So I decided to send a PR instead creating a new crate.

@hoodie
Copy link
Owner

hoodie commented Jul 12, 2023

@whizsid that sounds great. Looking forward to that. I was actually starting to rejuvenate mac-notification-sys a little. But I'm afraid we really ought to implement the new UNNotificationCenter api finally. Since I'm not a very experienced objective-c, nor macOS Desktop developer I appreciate any help and contribution I can get.

@Rutik7066
Copy link

/attempt tauri-apps/tauri#186

@mogery
Copy link

mogery commented Feb 11, 2024

/attempt

@Rutik7066
Copy link

Hi, @cheeseblubber Submitted PR.

@vivasvan1
Copy link

Is this solved or still open?

@hoodie
Copy link
Owner

hoodie commented Apr 22, 2024

still open

@vivasvan1
Copy link

@hoodie i'll look into it for feasiblity and update you.

@mogery
Copy link

mogery commented Apr 22, 2024

Looked into this one and it's very hard to do this without uprooting the whole library. For this to work on macOS, we would need to somehow ensure execution on the main thread, which is difficult without knowing whether the dependent project uses Tokio or not. It'd add a whole lot of hassle to using this library.

@ofek
Copy link

ofek commented Apr 22, 2024

Can we at least document a recommended alternative for Windows and macOS users?

@hoodie
Copy link
Owner

hoodie commented Apr 22, 2024

@mogery that's why I've avoided tackling this for so long. It's a tiny bit to complex to do on an on/off after-work kind of timeplan. Interestingly enough though it seems like the zed editor's implementation (native macos) might contain some good references on how to interact with the mac runtime in an async fashon.

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

10 participants