Skip to content

feat: replace deprecated NSUserNotifications with User Notifications#47817

Merged
VerteDinde merged 9 commits into
electron:mainfrom
Developer-Ecosystem-Engineering:update-to-usernotifications-framework
Mar 5, 2026
Merged

feat: replace deprecated NSUserNotifications with User Notifications#47817
VerteDinde merged 9 commits into
electron:mainfrom
Developer-Ecosystem-Engineering:update-to-usernotifications-framework

Conversation

@Developer-Ecosystem-Engineering
Copy link
Copy Markdown
Contributor

@Developer-Ecosystem-Engineering Developer-Ecosystem-Engineering commented Jul 17, 2025

Description of Change

Removes deprecated NSUserNotification API, now using User Notifications

It replaces API calls for generating, scheduling, and receiving native macOS notifications with equivalent API calls from the new framework, or functionally equivalent implementations.

To preserve the existing Notification module API, special handling was required in certain cases:

  • Dynamically declared notification actions

    • Typically, notification actions should be declared at app launch time when using the User Notifications framework. However, this isn’t compatible with Electron’s architecture. Instead, we dynamically declare new notifications actions when necessary and carefully manage the existing actions registered at runtime.
  • Localizations for ‘Reply’ and ‘Show’ labels

    • New translation files are added and processed through GRIT to add localizations for “Reply” and “Show” button labels which were initially supplied by the NSUserNotification framework.

Checklist

Release Notes

Notes: Replaced deprecated NSUserNotification with User Notifications

@welcome
Copy link
Copy Markdown

welcome Bot commented Jul 17, 2025

💖 Thanks for opening this pull request! 💖

Semantic PR titles

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Commit signing

This repo enforces commit signatures for all incoming PRs.
To sign your commits, see GitHub's documentation on Telling Git about your signing key.

PR tips

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jul 17, 2025
@VerteDinde VerteDinde self-assigned this Jul 17, 2025
@VerteDinde VerteDinde self-requested a review July 17, 2025 20:02
@VerteDinde VerteDinde added semver/patch backwards-compatible bug fixes no-backport labels Jul 17, 2025
Comment thread shell/browser/notifications/mac/cocoa_notification.mm Outdated
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Jul 18, 2025
@Developer-Ecosystem-Engineering
Copy link
Copy Markdown
Contributor Author

Waiting a few more days for all feedback, then will provide an update to incorporate. Running list thus far

  • Test failure
  • Commit Signing
  • Investigate using NotificationImageRetainer

Comment thread shell/browser/notifications/mac/notification_presenter_mac.mm
@Developer-Ecosystem-Engineering
Copy link
Copy Markdown
Contributor Author

Developer-Ecosystem-Engineering commented Aug 29, 2025

Test failure

  • requestAuthorizationWithOptions in the new UserNotifications framework requires the caller be code signed.

Commit Signing

  • Commits should be verified/signed now

Investigate using NotificationImageRetainer

  • Pattern should be updated in the latest change

@samuelmaddock
Copy link
Copy Markdown
Member

requestAuthorizationWithOptions in the new UserNotifications framework requires the caller be code signed.

From API WG review, the added requirement of code signing should be mentioned in the docs and added to the list of breaking changes.

Removes deprecated NSUserNotification API, now using User Notifications

It replaces API calls for generating, scheduling, and receiving native
macOS notifications with equivalent API calls from the new framework,
or functionally equivalent implementations.

To preserve the existing Notification module API, special handling was
required in certain cases:

  - Dynamically declared notification actions
    Typically, notification actions should be declared at app launch time
    when using the User Notifications framework. However, this isn’t
    compatible with Electron’s architecture. Instead, we dynamically
    declare new notifications actions when necessary and carefully manage
    the existing actions registered at runtime.

  - Localizations for ‘Reply’ and ‘Show’ labels
    New translation files are added and processed through GRIT to add
    localizations for “Reply” and “Show” button labels which were
    initially supplied by the NSUserNotification framework.
@VerteDinde VerteDinde force-pushed the update-to-usernotifications-framework branch from 8c0a5e2 to 478f9ca Compare March 4, 2026 21:08
@VerteDinde VerteDinde requested review from a team as code owners March 4, 2026 21:08
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Hello @Developer-Ecosystem-Engineering! It looks like this pull request touches one of our dependency or CI files, and per our contribution policy we do not accept these types of changes in PRs.

@VerteDinde VerteDinde dismissed github-actions[bot]’s stale review March 4, 2026 21:09

Dismissed, a maintainer pushed these changes to the branch

@VerteDinde VerteDinde changed the title refactor: replace deprecated NSUserNotifications with User Notifications feat: replace deprecated NSUserNotifications with User Notifications Mar 4, 2026
@VerteDinde VerteDinde added semver/minor backwards-compatible functionality and removed semver/patch backwards-compatible bug fixes labels Mar 4, 2026
Copy link
Copy Markdown
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

docs note: we should document the code-signing req in the Notifications tutorial and API docs on top of the breaking changes notice.

Comment thread docs/breaking-changes.md Outdated
Comment thread docs/breaking-changes.md Outdated
@VerteDinde VerteDinde requested review from erickzhao and reitowo March 5, 2026 03:29
Copy link
Copy Markdown
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

API LGTM

Copy link
Copy Markdown
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

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

API LGTM

In the API WG meeting, we discussed moving forward with these changes and fixing any issues that arise throughout the Electron 42 release process which sounds like a reasonable plan to me.

I also gave this a code review and it lgtm!

@VerteDinde VerteDinde merged commit d6fc627 into electron:main Mar 5, 2026
109 of 112 checks passed
@welcome
Copy link
Copy Markdown

welcome Bot commented Mar 5, 2026

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk
Copy link
Copy Markdown

release-clerk Bot commented Mar 5, 2026

Release Notes Persisted

Replaced deprecated NSUserNotification with User Notifications

WofWca added a commit to WofWca/electron that referenced this pull request May 8, 2026
This is a follow-up to
electron#47817.

According to https://www.electronjs.org/blog/electron-42-0#behavior-changed-macos-notifications-now-use-unnotification-api
> If an application is not code-signed, notifications will emit a `failed` event on the `Notification` object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants