notify

package
v1.17.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package notify is the numbering and the life of the notifications of an app on macOS and iOS (SPEC §29.9, §30.6) and, in center_darwin.go, UNUserNotificationCenter behind it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Ready says whether the app can show notifications: it needs a bundle with an identifier. The reason says why not.
	Ready() (ok bool, reason string)
	// Authorize asks the user for the permission, the first time, and returns whether it is granted. The errors of
	// the backend are NotificationsUnavailable already.
	Authorize(ctx context.Context) (granted bool, err error)
	// SetCategories gives the center the whole set of categories.
	SetCategories(cats []Category) error
	// Add shows the request, or replaces the one with its identifier.
	Add(ctx context.Context, req Request) error
	// Remove takes the notification with the identifier off the screen and out of the center.
	Remove(identifier string)
}

Backend is what the notifications ask of the system.

Flutter: no counterpart

type Category

type Category struct {
	ID      string
	Actions []mobile.Action
}

Category is a set of actions that notifications share, made from the buttons of a notification.

Flutter: no counterpart

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier is the numbering and the life of the notifications of the app. Its methods may be called from any goroutine.

Flutter: no counterpart

func New

func New(b Backend) *Notifier

New makes the notifier over the backend.

Flutter: no counterpart

func (*Notifier) Close

func (n *Notifier) Close(id uint32)

Close is the close that the app asks for. A notification that is gone is not an error.

Flutter: no counterpart

func (*Notifier) Response

func (n *Notifier) Response(identifier, actionID string)

Response is what the user did with the notification: actionID is the action that was chosen, mobile.DefaultAction for a click on the notification itself, and "" for a dismissal. It runs the callbacks of the app.

Flutter: no counterpart

func (*Notifier) Show

func (n *Notifier) Show(ctx context.Context, spec mobile.NotificationSpec) (uint32, error)

Show shows the notification: it is the number that is returned, the same number when the notification replaces one that is shown. It fails with NotificationsUnavailable when the app has no bundle, when the user refused the permission, and when the center refuses the request.

Flutter: no counterpart

func (*Notifier) Shutdown

func (n *Notifier) Shutdown()

Shutdown stops the timers; the notifications that are shown stay in the center, as the user's.

Flutter: no counterpart

type Request

type Request struct {
	// Identifier names the notification to the center; a request with the identifier of one that is shown replaces it.
	Identifier  string
	Title, Body string
	// Quiet makes no sound (UrgencyLow); Critical shows at the time-sensitive level (UrgencyCritical).
	Quiet, Critical bool
	// Category is the category that has the actions, "" for a notification without buttons that wants no dismiss
	// event either.
	Category string
	// IconPath is the file of the attachment, "" for none.
	IconPath string
}

Request is what is handed to the notification center: the content, and the category that has the buttons.

Flutter: no counterpart

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL