Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::events::PushNotifications Class Referenceabstract

Cross-platform local notification surface. More...

#include <push_notifications.hpp>

Public Member Functions

virtual ~PushNotifications ()=default
virtual bool is_available () const =0
 Returns true when a real notification backend is wired up on this build.
virtual std::string backend_id () const =0
 Short identifier of the active backend ("user-notifications", "libnotify", "winrt-toast-scaffold", or "none").
virtual void request_authorization (AuthorizationCallback callback)=0
 Ask the OS for permission to post notifications.
virtual NotificationAuthorization current_authorization () const =0
 Synchronous query for the current authorization state.
virtual uint64_t post_local_notification (const LocalNotification &notification)=0
 Post a notification.
virtual void set_handler (NotificationHandler handler)=0
 Register a callback that fires when the user activates a posted notification.
virtual bool cancel_notification (const std::string &id)=0
 Cancel a previously-posted notification by id (no-op if already dismissed).
virtual void cancel_all ()=0
 Cancel every notification this process has posted.

Static Public Member Functions

static PushNotifications & instance ()

Protected Member Functions

 PushNotifications ()=default
 PushNotifications (const PushNotifications &)=delete
PushNotifications & operator= (const PushNotifications &)=delete

Detailed Description

Cross-platform local notification surface.

Use the singleton via PushNotifications::instance(). The implementation is thread-safe: any thread may call post_local_notification, but the NotificationHandler is delivered on a platform-defined dispatch thread — callers must hop back to their own UI thread if the handler touches view state.

Constructor & Destructor Documentation

◆ ~PushNotifications()

virtual pulp::events::PushNotifications::~PushNotifications ( )
virtualdefault

◆ PushNotifications() [1/2]

pulp::events::PushNotifications::PushNotifications ( )
protecteddefault

◆ PushNotifications() [2/2]

pulp::events::PushNotifications::PushNotifications ( const PushNotifications & )
protecteddelete

Member Function Documentation

◆ backend_id()

virtual std::string pulp::events::PushNotifications::backend_id ( ) const
pure virtual

Short identifier of the active backend ("user-notifications", "libnotify", "winrt-toast-scaffold", or "none").

Useful for diagnostics and host reports.

◆ cancel_all()

virtual void pulp::events::PushNotifications::cancel_all ( )
pure virtual

Cancel every notification this process has posted.

◆ cancel_notification()

virtual bool pulp::events::PushNotifications::cancel_notification ( const std::string & id)
pure virtual

Cancel a previously-posted notification by id (no-op if already dismissed).

Returns true if the backend reported the cancellation.

◆ current_authorization()

virtual NotificationAuthorization pulp::events::PushNotifications::current_authorization ( ) const
pure virtual

Synchronous query for the current authorization state.

◆ instance()

PushNotifications & pulp::events::PushNotifications::instance ( )
static

◆ is_available()

virtual bool pulp::events::PushNotifications::is_available ( ) const
pure virtual

Returns true when a real notification backend is wired up on this build.

On false, request_authorization reports Unsupported and post_local_notification returns 0 without posting.

◆ operator=()

PushNotifications & pulp::events::PushNotifications::operator= ( const PushNotifications & )
protecteddelete

◆ post_local_notification()

virtual uint64_t pulp::events::PushNotifications::post_local_notification ( const LocalNotification & notification)
pure virtual

Post a notification.

Returns the assigned id (notification.id if non-empty, otherwise an auto-generated id) or 0 on failure / unavailable. The id is also surfaced to NotificationHandler if the user activates it.

◆ request_authorization()

virtual void pulp::events::PushNotifications::request_authorization ( AuthorizationCallback callback)
pure virtual

Ask the OS for permission to post notifications.

The callback fires once the platform has resolved the request (synchronously on backends that don't require an OS prompt, e.g. libnotify).

◆ set_handler()

virtual void pulp::events::PushNotifications::set_handler ( NotificationHandler handler)
pure virtual

Register a callback that fires when the user activates a posted notification.

Pass {} to clear.


The documentation for this class was generated from the following file: