Skip to content

docs: point user-facing notifications at go-macos/usernotifications - #4

Merged
tannevaled merged 1 commit into
mainfrom
document-usernotifications-successor
Aug 30, 2026
Merged

tannevaled merged 1 commit into
mainfrom
document-usernotifications-successor

Conversation

@tannevaled

Copy link
Copy Markdown
Collaborator

Documentation only — no non-comment change to any .go file, verified by
filtering the diff rather than by reading it.

PostUserNotification here drives NSUserNotification, deprecated since
macOS 11. The live API is UNUserNotificationCenter, now bound in
go-macos/usernotifications.

This package keeps everything the successor does not do — the Darwin notify(3)
bus and NSDistributedNotificationCenter, neither of which is a user-facing
banner — so it is not superseded, only narrowed. The docs now say which of the
two to reach for, instead of leaving a caller to find out from a deprecation.

One correction to what this package asserted: its doc said a block "cannot be
synthesised under CGO_ENABLED=0". That stopped being true when go-macos/objc
gained NewBlock in v0.3.0, and usernotifications uses real blocks.

UNUserNotificationCenter is now bound, in go-macos/usernotifications, so this
package should say which of the two to reach for. Documentation only: no
exported symbol, signature or behaviour changes, and PostUserNotification stays
exactly as it is for code already inside an .app that wants one line and no
authorization flow.

The division is by kind rather than by preference, and nothing here is
superseded. A user-facing notification belongs to the new package; the Darwin
notify(3) event bus and NSDistributedNotificationCenter are not user-facing at
all, have no counterpart in UserNotifications, and stay here -- a program that
needs both uses both.

PostUserNotification's godoc claimed UNUserNotificationCenter was "intentionally
not wrapped here", and this package's own doc.go explains why: a block "cannot
be synthesised from Go under CGO_ENABLED=0 without hand-assembling the block
ABI", and every UserNotifications completion handler is a block. That reasoning
was correct when it was written and stopped being true when go-macos/objc gained
NewBlock in v0.3.0. The claim is replaced with what actually happened.

Two differences a reader needs before switching are called out in both the godoc
and the README, because neither is obvious and one is fatal: asking
UNUserNotificationCenter for the centre without a bundle identifier throws an
Objective-C exception and ABORTS the process, where PostUserNotification merely
returns ErrNoUserCenter; and the new API requires the user to grant
authorization, where this one asks nobody.
@tannevaled
tannevaled merged commit f8de089 into main Aug 30, 2026
3 checks passed
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.

1 participant