Skip to content

feat: add Notification.getHistory() for macOS#51123

Merged
VerteDinde merged 7 commits into
42-x-yfrom
trop/42-x-y-bp-feat-add-notification-gethistory-for-macos-1776383355973
Apr 22, 2026
Merged

feat: add Notification.getHistory() for macOS#51123
VerteDinde merged 7 commits into
42-x-yfrom
trop/42-x-y-bp-feat-add-notification-gethistory-for-macos-1776383355973

Conversation

@trop
Copy link
Copy Markdown
Contributor

@trop trop Bot commented Apr 16, 2026

Backport of #50325

See that PR for details.

Notes: Added Notification.getHistory() for macOS, allowing developers to restore all delivered notifications still present in Notification Center.

trop Bot and others added 7 commits April 16, 2026 23:49
Add `Notification.getHistory()` which returns a `Promise<Notification[]>`
of all delivered notifications still present in Notification Center.

Each returned Notification is a live object connected to the corresponding
delivered notification — interaction events (click, reply, action, close)
will fire on these objects, enabling apps to re-attach event handlers after
a restart.

Key implementation details:
- Queries UNUserNotificationCenter's getDeliveredNotifications API
- Creates live Notification objects with populated id, groupId, title,
  subtitle, and body properties from what macOS provides
- Registers each object with the presenter via Restore() so the
  NotificationCenterDelegate routes events correctly
- Restored notifications use is_restored_ flag to prevent removal from
  Notification Center when the JS object is garbage collected
- Requires code-signed builds (unsigned builds resolve with empty array)

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Notifications returned by getHistory() now set is_restored_ so that Dismiss() skips removal from Notification Center on GC. Calling show() on a restored notification removes the original from NC and posts a new one.

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Erick Zhao <erick@hotmail.ca>

Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
@trop trop Bot requested review from a team and VerteDinde April 16, 2026 23:49
@trop trop Bot added 42-x-y backport This is a backport PR backport/requested 🗳 semver/minor backwards-compatible functionality labels Apr 16, 2026
Copy link
Copy Markdown
Member

@VerteDinde VerteDinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on behalf of @electron/wg-releases

@VerteDinde VerteDinde merged commit a3d215d into 42-x-y Apr 22, 2026
83 checks passed
@release-clerk
Copy link
Copy Markdown

release-clerk Bot commented Apr 22, 2026

Release Notes Persisted

Added Notification.getHistory() for macOS, allowing developers to restore all delivered notifications still present in Notification Center.

@VerteDinde VerteDinde deleted the trop/42-x-y-bp-feat-add-notification-gethistory-for-macos-1776383355973 branch April 22, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

42-x-y backport/approved ✅ backport This is a backport PR semver/minor backwards-compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant