mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* 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>
47 lines
1.3 KiB
Objective-C
47 lines
1.3 KiB
Objective-C
// Copyright (c) 2015 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
|
|
#define ELECTRON_SHELL_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <UserNotifications/UserNotifications.h>
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
#include "shell/browser/notifications/notification.h"
|
|
|
|
namespace electron {
|
|
|
|
class CocoaNotification : public Notification {
|
|
public:
|
|
CocoaNotification(NotificationDelegate* delegate,
|
|
NotificationPresenter* presenter);
|
|
~CocoaNotification() override;
|
|
|
|
// Notification:
|
|
void Show(const NotificationOptions& options) override;
|
|
void Dismiss() override;
|
|
|
|
void NotificationDisplayed();
|
|
void NotificationReplied(const std::string& reply);
|
|
void NotificationActivated(int actionIndex);
|
|
void NotificationDismissed();
|
|
|
|
UNNotificationRequest* notification_request() const {
|
|
return notification_request_;
|
|
}
|
|
|
|
private:
|
|
void LogAction(const char* action);
|
|
void ScheduleNotification(UNMutableNotificationContent* content);
|
|
|
|
UNNotificationRequest* __strong notification_request_;
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
|