Skip to content

Add an API and backends for system notifications#15351

Draft
Kontrabant wants to merge 6 commits intolibsdl-org:mainfrom
Kontrabant:notifications2
Draft

Add an API and backends for system notifications#15351
Kontrabant wants to merge 6 commits intolibsdl-org:mainfrom
Kontrabant:notifications2

Conversation

@Kontrabant
Copy link
Copy Markdown
Contributor

@Kontrabant Kontrabant commented Apr 9, 2026

Notifications are asynchronous, passive popups that convey some information to the user. This adds support for various native system notifications and an associated SDL API.

Tested and supported platforms:

  • *nix via D-Bus interfaces (both the "core" interface and a portal for use within containers is supported)
  • macOS (10.14+, only supported when used within app bundles due to internal OS requirements)
  • Windows (Win10+, technically Win8 supported notifications, but some newer interfaces that require Win10 are used, and Win8 usage is basically zero at this point)

Needs testing:

  • iOS (builds, but currently untested. My old MacBook can't run a new enough XCode to target my phone)

Possible future backends:

  • Android (this is certainly doable, but I have zero experience with Android and no devices to test it on.)
  • Emscripten (browsers support notification functionality, so this is probably doable?)

All implementations currently support some basic features in addition to header and body text:

  • An attached image
  • Actions for user feedback (presentation is system dependent, but usually buttons or menu items)
  • Custom sounds (some platforms restrict where the sound files can be located, with Windows being particularly restrictive)

Feedback from actions comes in the form of a new event, which returns the invoked action string specified when the notification was dispatched. It can also return a "default" action, if the notification is interacted with in a non-specific way (e.g. tapping or clicking on the body instead of a button).

New capabilities can be easily added by adding additional properties. A simple interface that just takes a title, body, and image, is included as well.

The Windows implementation also provides a situation where SDL_wcstoul() is needed, so that was added in a separate commit, along with associated tests.

Closes #7857 (supersedes)
Closes #1932

@Kontrabant Kontrabant marked this pull request as draft April 9, 2026 17:14
@Kontrabant Kontrabant force-pushed the notifications2 branch 2 times, most recently from d53972e to ef3fe10 Compare April 9, 2026 17:36
@Kontrabant Kontrabant added this to the 3.6.0 milestone Apr 9, 2026
Comment thread include/SDL3/SDL_notification.h Outdated
Comment thread src/events/SDL_notificationevents.c Outdated
@Kontrabant Kontrabant force-pushed the notifications2 branch 2 times, most recently from 7256624 to ea0bf0e Compare April 13, 2026 17:51
Use the core and portal notification implementations to dispatch system notifications.
Notifications are supported on Win10 and above.
Supported on macOS 10.14+ and iOS.
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

Successfully merging this pull request may close these issues.

Add System Notification Support

2 participants