#Notification API misses TimestampTrigger
1 messages · Page 1 of 1 (latest)
Tracking issue: https://github.com/tauri-apps/tauri/issues/5222
idk but i don't recommend really waiting for this. Even google stopped working on the Notification Triggers Web API because they weren't able to implement it nicely and reliable in a cross-platform way
Is there any other way to do scheduled notifictations?
hmm, maybe setup a timer/timeout yourself. that would of course require the app to still be open when the notification should be displayed
What if I would use the System Tray thingy? then it will run in background
Accorinding to https://tauri.app/v1/guides/features/system-tray#keep-the-app-running-in-the-background-after-closing-all-windows
still requires that the user does not close the whole app. But yes, it's less likely that they will close it completely if you do this
you could also do it without a system tray icon btw
Oke
I got it working...
if ("__TAURI__" in window) {
class TimestampTrigger{
constructor(timestamp) {this.timestamp = timestamp;}
}
window.TimestampTrigger = TimestampTrigger;
Notification.showNotification = (title, option={}) => {
if (typeof(title) == 'object') option = title;
if (!("title" in option)) option.title = title;
if ("showTrigger" in option) setTimeout(() => new Notification(option.title, option), option.showTrigger.timestamp - new Date().getTime());
else new Notification(option.title, option);
}
}
For if anyone want to use
Hey uhmm with the background running thingy: I wanted to have double click to open the window, but now I get thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src\main.rs:60:49
for:
let window = app.get_window("main").unwrap();
that means that the main windows doesn't exist anymore (= it was closed)
it is/was hidden
can you show your code? Because if that'd be the case the panic would not make sense
It is too big
yes
(you can upload .rs files directly)
I will have to remove the spaces and replace with tabs
o
Oh wait I see it. The ExitRequested thingy might be the problem here
because with the tray it just works fine
yeah that's what i meant. ExitRequested only prevents the eventloop from exiting (the thing that keeps the tray alive). The window will still be closed. You need to handle the CloseRequested window event
Maybe I need to use https://tauri.app/v1/guides/features/window-customization to do this
To just get a different type of close button function
Or there is a better way? Can you come up with some code?
that wouldn't catch stuff like right click -> close on the taskbar icon
i already told you
Fine, I want that one to be QUIT and to completely stop the window
But how to implement it I mean
either via the RunEvent like you did for ExitRequested or via the js api/event: https://tauri.app/v1/api/js/window#oncloserequested
I need to do it using the Rust code, cause the js is also for website edition
tauri::RunEvent::CloseRequested { api, .. } => {
api.prevent_close();
}
maybe
error[E0599]: no variant named CloseRequested found for enum RunEvent
if I click yes, the window is gone, but the tray not and then when I double click (or just select Show) then it again give thread 'main' panicked at 'called `Option::unwrap()` on a `None` value'
this was just an example to show you how to react to the CloseRequested event