-
Notifications
You must be signed in to change notification settings - Fork 300
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
[feat] Notification onclick event #2150
Comments
Click events aren't implemented yet. |
Is there any ETA on this? |
I don't know if this belongs in the same issue, but click focuses the (main) window for me on Ubuntu and macOS, but not on Windows (10). It would be nice to be consistent if possible. I unsuccessfully tried to figure out whether rust-notify supports this. |
Anything that can be done to develop this? New to Open Source if any references and guides to help then I would like to help with this feature. |
@Huzaifa-MS the problem is that the upstream notification crates (https://github.com/hoodie/notify-rust and its dependencies) don't support this, so you'd have to work with ugly system APIs to implement this. |
@FabianLars I see. I did get that vibe from searching for a bit. I also noticied that the web api for notification works on its own in the frontend. Is it possible to use that to create actions in notifications? |
It doesn't. We're injecting our own api (the same from the api module) here: https://github.com/tauri-apps/tauri/blob/dev/core/tauri/scripts/core.js#L163-L247 |
I am sorry, I am new to this so perhaps I am not understanding. const callWebNotificationAPI = async () => {
Notification
if (!("Notification" in window)) {
// Check if the browser supports notifications
alert("This browser does not support desktop notification")
} else if (Notification.permission === "granted") {
// Check whether notification permissions have already been granted;
// if so, create a notification
new Notification("Hi there!")
// …
} else if (Notification.permission !== "denied") {
// We need to ask the user for permission
Notification.requestPermission().then((permission) => {
// If the user accepts, let's create a notification
if (permission === "granted") {
new Notification("Hi there!")
}
})
}
} Is getting transformed by Tauri automatically at compile time to use Tauri's notification library instead? Does Tauri not support this web API yet? |
We don't touch your code at all. We overwrite the global
Tauri does. But the underlying webviews don't, by design as far as i know. They expect the host process to handle/implement notifications, which we do by overwriting the js apis to use our rust api. |
I see. I understand better now. Thank you. |
@
Do you of any guides or documentation I can look into to implement the feature? I would like to try my hand at it. |
Is there any way to use the JS APIs instead? |
There are no JS APIs to use. The web apis you know from normal browsers don't exist in webviews and we need to polyfill them ourselves. And the nodejs apis can't be used because there is no nodejs runtime in tauri. Or did you mean something different? |
Completely understood, thank you. The lack of click handlers is really only a problem on MacOS and why I had hoped to pipe notifications through a webview. Other platforms seem to respect the |
Any updates? |
Describe the problem
I am running my Tauri app in the tray and I only want to show the UI when the user responds to a notification. I can't seem to subscribe to any notification onclick event.
Describe the solution you'd like
I would like to be able to subscribe to a click event, like so:
Alternatives considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: