Add an API and backends for system notifications#15351
Conversation
d53972e to
ef3fe10
Compare
ea0bf0e to
c752640
Compare
391c8dc to
0d56d7b
Compare
|
Fixed a few memory leaks, and revamped the data structure used to add "actions" to notifications, so it can be easily extended in the future to support additional types. The basic design here is complete, so I'm removing draft status. |
0d56d7b to
d9a5652
Compare
|
I haven't done a thorough review, but in general this looks good to me. @icculus, thoughts? |
1c1db86 to
2804d6a
Compare
Includes the appropriate automated tests.
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.
|
@icculus, any idea what needs to be done for Emscripten? This seems like a useful API to add. |
|
So there is an API for this, but:
If those things happen, the API is actually pretty usable. I see we have an API to request permission, but no way to find out if permission was denied; is this running on the idea that even if approved, notifications can be blocked? I guess on Emscripten, if the app asks for permission, we'll hold it until the next time the user clicks on something, which can weird if the user triggered this by clicking on an "enable notifications" button...but otherwise they'll need to have an SDL event watcher to catch it in time. |
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:
Needs testing:
Possible future backends:
All implementations currently support some basic features in addition to header and body text:
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