mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: replace deprecated NSUserNotifications with User Notifications (#47817)
* refactor: replace deprecated NSUserNotifications with User Notifications
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.
* Use NotificationImageRetainer pattern from //chrome
* build: fix lint
* build: update config to handle --translate-gender for pak files
* test: also sign on arm64
* fix: add error handling for scheduling notification
* docs: add details to breaking changes
* docs: clarify breaking change details
* docs: add details for notifications tutorial and API documentation
---------
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
This commit is contained in:
committed by
GitHub
parent
7c0cb61b3c
commit
d6fc627ba5
@@ -8,6 +8,12 @@ Process: [Main](../glossary.md#main-process)
|
||||
> If you want to show notifications from a renderer process you should use the
|
||||
> [web Notifications API](../tutorial/notifications.md)
|
||||
|
||||
> [!NOTE]
|
||||
> On MacOS, notifications use the UNNotification API as their underlying framework.
|
||||
> This API requires an application to be code-signed in order for notifications
|
||||
> to appear. Unsigned binaries will emit a `failed` event when notifications
|
||||
> are called.
|
||||
|
||||
## Class: Notification
|
||||
|
||||
> Create OS desktop notifications
|
||||
|
||||
@@ -14,6 +14,14 @@ This document uses the following convention to categorize breaking changes:
|
||||
|
||||
## Planned Breaking API Changes (42.0)
|
||||
|
||||
### Behavior Changed: macOS notifications now use `UNNotification` API
|
||||
|
||||
Electron has migrated from the deprecated `NSUserNotification` API to the
|
||||
[`UNNotification`](https://developer.apple.com/documentation/usernotifications)
|
||||
API on macOS. The new API requires that an application be code-signed in order
|
||||
for notifications to be displayed. If an application is not code-signed,
|
||||
notifications will emit a `failed` event on the `Notification` object.
|
||||
|
||||
### Behavior Changed: Offscreen rendering will use `1.0` as default device scale factor.
|
||||
|
||||
Previously, OSR used the primary display's device scale factor for rendering, which made the output frame size vary across users.
|
||||
|
||||
@@ -142,8 +142,12 @@ notification away.
|
||||
|
||||
### macOS
|
||||
|
||||
Notifications are straightforward on macOS, but you should be aware of
|
||||
[Apple's Human Interface guidelines regarding notifications][apple-notification-guidelines].
|
||||
For notifications on macOS, your application will need to be code-signed in order
|
||||
for notification events to emit correctly. This requirement stems from the underlying
|
||||
UNNotification API provided by Apple. Unsigned binaries will emit a `failed` event
|
||||
when notification APIs are called.
|
||||
|
||||
Additionally, you should be aware of [Apple's Human Interface guidelines regarding notifications][apple-notification-guidelines].
|
||||
|
||||
Note that notifications are limited to 256 bytes in size and will be truncated
|
||||
if you exceed that limit.
|
||||
|
||||
Reference in New Issue
Block a user