docs: point user-facing notifications at go-macos/usernotifications - #4
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documentation only — no non-comment change to any
.gofile, verified byfiltering the diff rather than by reading it.
PostUserNotificationhere drivesNSUserNotification, deprecated sincemacOS 11. The live API is
UNUserNotificationCenter, now bound ingo-macos/usernotifications.This package keeps everything the successor does not do — the Darwin
notify(3)bus and
NSDistributedNotificationCenter, neither of which is a user-facingbanner — 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/objcgained
NewBlockin v0.3.0, andusernotificationsuses real blocks.