-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add support for sending desktop notifications #1338
Comments
I would find this feature quite useful for turn-based games! People can chat in the middle of turns, and it's likely that a person may do other stuff, but a player would still like to return to the game when something interesting happens. 🙂 I believe this could also be used for simple matchmaking purposes (useful for the web). |
This could also be included on android using LocalNotification, it just needs a couple of additional parameters. There is already a module that does this but if we're doing it on desktop we might as well do it on other platforms where possible. HTML5 might also be possible. Probaly ios too but I don't know. |
Just when I'm in need of such thing. Looked through your https://github.com/Calinou/godot/tree/add-os-notifications branch and it looks like there is some work in progress, added comment to your commit with fix for removing try icon (tested, sending multiple notification works now). Then there is another issue, icons. While I was able to make single .png icon to display, separating them into small (tray icon) and big (the one on notification box) will be more challenging.
|
This could probably be implemented with a script; I mean a shell/powershell script. Said script can be called via |
Posting Oen44's comment on my branch in case it gets lost by a force push: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Having: Would be a very good dream. I am having problems with the service worker module on another question, and that function, it would to have to be implemented on the service worker as well, right? Then, having a way to comunicate with the worker from inside the project as well, we could have server-client and project-client cross platform notification on PWA exports. |
@PeterMarques You can already use those APIs by calling JavaScript code from GDScript in the exported project: https://docs.godotengine.org/en/stable/classes/class_javascript.html In 3.4 and later, you can also call GDScript code from JavaScript: https://godotengine.org/article/godot-web-progress-report-9 |
Okay, so thats half of the work, i will try to do the Engine-JS thing later, but as a background service to recieve notifications even when not running, then, it needs to be instanciated on the Service.Worker, right? |
You should be able to register a service worker by calling JavaScript code. The service worker is always pure JavaScript code, it can't call into Godot's runtime functions. |
I also think that this is necessary in the engine, it is often used in programs, launchers, etc. Just don’t just display a message - but render a canvas or window in the notification area so that you can create a menu and customize a theme in it. |
The issue is that custom notifications don't follow the OS theming, accessibility or do-not-disturb settings. We should really be using OS-provided notification APIs for this 🙂 In terms of implementation complexity, it ends up being similar anyway. |
So is there any progress on how to send desktop notifications on Linux/Windows or other platforms? |
To my knowledge, nobody is currently working on implementing this. |
For macOS/iOS this would be implemented via UNUserNotificationCenter which also has a nice system for responding to user interactions with the notification via UNUserNotificationCenterDelegate. I'm not familiar with Windows or Linux notification systems, but perhaps there is something similar there to support getting a user response to a notification? For this reason I think it would be very nice to include an optional interaction callback in the notification call: Where the |
Describe the project you are working on:
The Godot editor 🙂
Describe the problem or limitation you are having in your project:
It's currently impossible to send desktop notifications from a Godot project (or the editor) in a cross-platform manner. It's possible to run
notify-send
usingOS.execute()
, but that only works on Linux/BSD.There are many use cases for sending desktop notifications in projects:
We could also benefit from integrating them in the Godot editor:
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
There could be a method in the OS singleton to send a desktop notification:
The custom icon is optional. If it's
null
(the default), the project icon will be used for the notification icon.The duration is specified in seconds. If it's
-1
(the default), the OS-provided default will be used. (Note that this value can vary across platforms and configurations to match the user's accessibility settings.)If the duration is
0
, the notification will never go away and will have to be discarded manually (this may not be supported on all platforms).Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
On Windows 10, the result would look something like this:
We could perhaps integrate the portablefiledialogs library to implement this feature. On top of sending desktop notifications, it also supports spawning message dialogs and native file choosers (which may be useful for non-game applications made with Godot). On the HTML5 platform, the Web Notifications API could be used to implement this feature.
I also have a WIP branch which currently only supports Windows, but doesn't add any third-party libraries.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
No (except on Linux using
notify-send
).Is there a reason why this should be core and not an add-on in the asset library?:
It might be possible to provide this functionality using a GDNative add-on. However, we may want to use this feature in the editor as described above for convenience reasons.
The text was updated successfully, but these errors were encountered: