Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Send ¶
func Send(data NotificationData) error
Send is a convenience function for sending notifications. If a default notifier has been set via SetDefaultNotifier(), it will be used (enabling action callbacks like OpenURL and OpenPath). Otherwise, a temporary notifier with default settings is created.
func SetDefaultNotifier ¶
func SetDefaultNotifier(n *Notifier)
SetDefaultNotifier sets the package-level notifier used by Send(). This allows the application to configure action callbacks (OpenURL, OpenPath) that will be used for all notifications sent via Send().
Types ¶
type NotificationData ¶
type NotificationData struct {
Title string `json:"title" mapstructure:"title"`
Message string `json:"message" mapstructure:"message"`
Icon string `json:"icon,omitempty" mapstructure:"icon"`
Duration int `json:"duration,omitempty" mapstructure:"duration"` // Duration in milliseconds
ActionURL string `json:"actionUrl,omitempty" mapstructure:"actionUrl"` // URL to open when notification is clicked
ActionPath string `json:"actionPath,omitempty" mapstructure:"actionPath"` // File/folder path to open when notification is clicked
Sound string `json:"sound,omitempty" mapstructure:"sound"` // Path to sound file to play
}
NotificationData represents the data needed for a notification
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier handles desktop notifications
func GetDefaultNotifier ¶
func GetDefaultNotifier() *Notifier
GetDefaultNotifier returns the package-level notifier, or nil if not set.
func NewNotifier ¶
func NewNotifier(opts NotifierOptions) (*Notifier, error)
NewNotifier creates a new notification handler
type NotifierOptions ¶
type NotifierOptions struct {
// AppName is shown in notifications (defaults to "System Bridge")
AppName string
// SoundFile is the default sound file path (optional)
SoundFile string
// OpenURL is called when a notification with ActionURL is clicked
OpenURL func(string) error
// OpenPath is called when a notification with ActionPath is clicked
OpenPath func(string) error
}
NotifierOptions contains optional configuration for creating a Notifier