You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No way to post a user notification (banner/alert). The current and correct
API is the UserNotifications framework — UNUserNotificationCenter,
which replaced the deprecated NSUserNotification / NSUserNotificationCenter
(deprecated since macOS 11, unreliable now). This is the cocoa counterpart of
freedesktop org.freedesktop.Notifications (react-x11#353).
The bundle-identity constraint (the main gotcha)
UNUserNotificationCenter.current() delivers nothing — and can throw — unless
the process is a code-signed .app bundle with a real CFBundleIdentifier.
The cocoa backend runs today as a bare node process whose CFBundleIdentifier
is null, so UN… posts silently do nothing until the app is packaged. The
bridge should make this a capability the renderer can read, not a silent
drop — e.g. a notificationsAvailable() / settings query that reflects whether
a bundle id resolves — so the consumer can fall to its osascript rung
instead.
Proposed API (mechanism only; policy stays in the renderer)
native.requestNotificationAuthorization(['alert','sound','badge'], cb) // cb(granted)
native.notificationSettings(cb) // authorization status + which are enabled + bundle-id present
const id = native.postNotification({
identifier?, // stable id; reusing one REPLACES the banner (the replaces_id case)
title, subtitle?, body?,
sound?: 'default' | null,
categoryId?, // ties to a registered action set
userInfo?, // opaque, round-tripped back on action / dismiss
})
native.updateNotification(id, { … }) // = post with the same identifier
native.removeNotification(id) // removeDeliveredNotificationsWithIdentifiers:
native.setNotificationCategories([
{ id, actions: [{ id, title, destructive?, foreground? }] },
])
// backend events:
// notification-action { identifier, actionId, userInfo }
// notification-dismissed { identifier, reason }
Set a UNUserNotificationCenterDelegate at startup so a banner acted on
while the app is running routes back (didReceive), and so willPresent
can show banners while the app is foregrounded.
NSUserNotification is prior art but deprecated — target UN….
Consumer
react-x11 notifications, the macOS half of react-x11#353. See docs/macos.md.
Activity