Merge pull request #9837 from electron/notification-actions

Notification actions
This commit is contained in:
Kevin Sawicki 2017-06-28 12:59:10 -07:00 committed by GitHub
commit 0f83180377
16 changed files with 192 additions and 105 deletions

View file

@ -14,8 +14,35 @@
#include "brightray/browser/browser_client.h" #include "brightray/browser/browser_client.h"
#include "native_mate/constructor.h" #include "native_mate/constructor.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace mate {
template<>
struct Converter<brightray::NotificationAction> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
brightray::NotificationAction* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
if (!dict.Get("type", &(out->type))) {
return false;
}
dict.Get("text", &(out->text));
return true;
}
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
brightray::NotificationAction val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("text", val.text);
dict.Set("type", val.type);
return dict.GetHandle();
}
};
} // namespace mate
namespace atom { namespace atom {
namespace api { namespace api {
@ -38,6 +65,7 @@ Notification::Notification(v8::Isolate* isolate,
opts.Get("silent", &silent_); opts.Get("silent", &silent_);
opts.Get("replyPlaceholder", &reply_placeholder_); opts.Get("replyPlaceholder", &reply_placeholder_);
opts.Get("hasReply", &has_reply_); opts.Get("hasReply", &has_reply_);
opts.Get("actions", &actions_);
} }
} }
@ -97,6 +125,19 @@ void Notification::SetHasReply(bool new_has_reply) {
has_reply_ = new_has_reply; has_reply_ = new_has_reply;
} }
void Notification::SetActions(
const std::vector<brightray::NotificationAction>& actions) {
actions_ = actions;
}
std::vector<brightray::NotificationAction> Notification::GetActions() {
return actions_;
}
void Notification::NotificationAction(int index) {
Emit("action", index);
}
void Notification::NotificationClick() { void Notification::NotificationClick() {
Emit("click"); Emit("click");
} }
@ -121,8 +162,16 @@ void Notification::Show() {
if (presenter_) { if (presenter_) {
notification_ = presenter_->CreateNotification(this); notification_ = presenter_->CreateNotification(this);
if (notification_) { if (notification_) {
notification_->Show(title_, body_, "", GURL(), icon_.AsBitmap(), silent_, brightray::NotificationOptions options;
has_reply_, reply_placeholder_); options.title = title_;
options.msg = body_;
options.icon_url = GURL();
options.icon = icon_.AsBitmap();
options.silent = silent_;
options.has_reply = has_reply_;
options.reply_placeholder = reply_placeholder_;
options.actions = actions_;
notification_->Show(options);
} }
} }
} }
@ -144,7 +193,9 @@ void Notification::BuildPrototype(v8::Isolate* isolate,
.SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder, .SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder,
&Notification::SetReplyPlaceholder) &Notification::SetReplyPlaceholder)
.SetProperty("hasReply", &Notification::GetHasReply, .SetProperty("hasReply", &Notification::GetHasReply,
&Notification::SetHasReply); &Notification::SetHasReply)
.SetProperty("actions", &Notification::GetActions,
&Notification::SetActions);
} }
} // namespace api } // namespace api

View file

@ -31,6 +31,7 @@ class Notification : public mate::TrackableObject<Notification>,
v8::Local<v8::FunctionTemplate> prototype); v8::Local<v8::FunctionTemplate> prototype);
// NotificationDelegate: // NotificationDelegate:
void NotificationAction(int index) override;
void NotificationClick() override; void NotificationClick() override;
void NotificationReplied(const std::string& reply) override; void NotificationReplied(const std::string& reply) override;
void NotificationDisplayed() override; void NotificationDisplayed() override;
@ -51,6 +52,7 @@ class Notification : public mate::TrackableObject<Notification>,
bool GetSilent(); bool GetSilent();
base::string16 GetReplyPlaceholder(); base::string16 GetReplyPlaceholder();
bool GetHasReply(); bool GetHasReply();
std::vector<brightray::NotificationAction> GetActions();
// Prop Setters // Prop Setters
void SetTitle(const base::string16& new_title); void SetTitle(const base::string16& new_title);
@ -58,6 +60,7 @@ class Notification : public mate::TrackableObject<Notification>,
void SetSilent(bool new_silent); void SetSilent(bool new_silent);
void SetReplyPlaceholder(const base::string16& new_reply_placeholder); void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
void SetHasReply(bool new_has_reply); void SetHasReply(bool new_has_reply);
void SetActions(const std::vector<brightray::NotificationAction>& actions);
private: private:
base::string16 title_; base::string16 title_;
@ -68,6 +71,7 @@ class Notification : public mate::TrackableObject<Notification>,
bool silent_ = false; bool silent_ = false;
base::string16 reply_placeholder_; base::string16 reply_placeholder_;
bool has_reply_ = false; bool has_reply_ = false;
std::vector<brightray::NotificationAction> actions_;
brightray::NotificationPresenter* presenter_; brightray::NotificationPresenter* presenter_;

View file

@ -4,6 +4,8 @@
#include "brightray/browser/linux/libnotify_notification.h" #include "brightray/browser/linux/libnotify_notification.h"
#include <vector>
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
@ -83,17 +85,10 @@ LibnotifyNotification::~LibnotifyNotification() {
} }
} }
void LibnotifyNotification::Show(const base::string16& title, void LibnotifyNotification::Show(const NotificationOptions& options) {
const base::string16& body,
const std::string& tag,
const GURL& icon_url,
const SkBitmap& icon,
bool silent,
bool has_reply,
const base::string16& reply_placeholder) {
notification_ = libnotify_loader_.notify_notification_new( notification_ = libnotify_loader_.notify_notification_new(
base::UTF16ToUTF8(title).c_str(), base::UTF16ToUTF8(options.title).c_str(),
base::UTF16ToUTF8(body).c_str(), base::UTF16ToUTF8(options.msg).c_str(),
nullptr); nullptr);
g_signal_connect( g_signal_connect(
@ -107,8 +102,8 @@ void LibnotifyNotification::Show(const base::string16& title,
nullptr); nullptr);
} }
if (!icon.drawsNothing()) { if (!options.icon.drawsNothing()) {
GdkPixbuf* pixbuf = libgtkui::GdkPixbufFromSkBitmap(icon); GdkPixbuf* pixbuf = libgtkui::GdkPixbufFromSkBitmap(options.icon);
libnotify_loader_.notify_notification_set_image_from_pixbuf( libnotify_loader_.notify_notification_set_image_from_pixbuf(
notification_, pixbuf); notification_, pixbuf);
libnotify_loader_.notify_notification_set_timeout( libnotify_loader_.notify_notification_set_timeout(
@ -116,8 +111,8 @@ void LibnotifyNotification::Show(const base::string16& title,
g_object_unref(pixbuf); g_object_unref(pixbuf);
} }
if (!tag.empty()) { if (!options.tag.empty()) {
GQuark id = g_quark_from_string(tag.c_str()); GQuark id = g_quark_from_string(options.tag.c_str());
g_object_set(G_OBJECT(notification_), "id", id, NULL); g_object_set(G_OBJECT(notification_), "id", id, NULL);
} }

View file

@ -6,6 +6,7 @@
#define BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_NOTIFICATION_H_ #define BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_NOTIFICATION_H_
#include <string> #include <string>
#include <vector>
#include "brightray/browser/linux/libnotify_loader.h" #include "brightray/browser/linux/libnotify_loader.h"
#include "brightray/browser/notification.h" #include "brightray/browser/notification.h"
@ -22,14 +23,7 @@ class LibnotifyNotification : public Notification {
static bool Initialize(); static bool Initialize();
// Notification: // Notification:
void Show(const base::string16& title, void Show(const NotificationOptions& options) override;
const base::string16& msg,
const std::string& tag,
const GURL& icon_url,
const SkBitmap& icon,
bool silent,
bool has_reply,
const base::string16& reply_placeholder) override;
void Dismiss() override; void Dismiss() override;
private: private:

View file

@ -8,6 +8,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#include <string> #include <string>
#include <vector>
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "brightray/browser/notification.h" #include "brightray/browser/notification.h"
@ -21,23 +22,18 @@ class CocoaNotification : public Notification {
~CocoaNotification(); ~CocoaNotification();
// Notification: // Notification:
void Show(const base::string16& title, void Show(const NotificationOptions& options) override;
const base::string16& msg,
const std::string& tag,
const GURL& icon_url,
const SkBitmap& icon,
bool silent,
const bool has_reply,
const base::string16& reply_placeholder) override;
void Dismiss() override; void Dismiss() override;
void NotificationDisplayed(); void NotificationDisplayed();
void NotificationReplied(const std::string& reply); void NotificationReplied(const std::string& reply);
void NotificationButtonClicked();
NSUserNotification* notification() const { return notification_; } NSUserNotification* notification() const { return notification_; }
private: private:
base::scoped_nsobject<NSUserNotification> notification_; base::scoped_nsobject<NSUserNotification> notification_;
int action_index_;
DISALLOW_COPY_AND_ASSIGN(CocoaNotification); DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
}; };

View file

@ -6,6 +6,7 @@
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/notification_delegate.h" #include "brightray/browser/notification_delegate.h"
#include "brightray/browser/notification_presenter.h" #include "brightray/browser/notification_presenter.h"
#include "skia/ext/skia_utils_mac.h" #include "skia/ext/skia_utils_mac.h"
@ -23,33 +24,38 @@ CocoaNotification::~CocoaNotification() {
removeDeliveredNotification:notification_]; removeDeliveredNotification:notification_];
} }
void CocoaNotification::Show(const base::string16& title, void CocoaNotification::Show(const NotificationOptions& options) {
const base::string16& body,
const std::string& tag,
const GURL& icon_url,
const SkBitmap& icon,
bool silent,
bool has_reply,
const base::string16& reply_placeholder) {
notification_.reset([[NSUserNotification alloc] init]); notification_.reset([[NSUserNotification alloc] init]);
[notification_ setTitle:base::SysUTF16ToNSString(title)]; [notification_ setTitle:base::SysUTF16ToNSString(options.title)];
[notification_ setInformativeText:base::SysUTF16ToNSString(body)]; [notification_ setInformativeText:base::SysUTF16ToNSString(options.msg)];
if ([notification_ respondsToSelector:@selector(setContentImage:)] && if ([notification_ respondsToSelector:@selector(setContentImage:)] &&
!icon.drawsNothing()) { !options.icon.drawsNothing()) {
NSImage* image = skia::SkBitmapToNSImageWithColorSpace( NSImage* image = skia::SkBitmapToNSImageWithColorSpace(
icon, base::mac::GetGenericRGBColorSpace()); options.icon, base::mac::GetGenericRGBColorSpace());
[notification_ setContentImage:image]; [notification_ setContentImage:image];
} }
if (silent) { if (options.silent) {
[notification_ setSoundName:nil]; [notification_ setSoundName:nil];
} else { } else {
[notification_ setSoundName:NSUserNotificationDefaultSoundName]; [notification_ setSoundName:NSUserNotificationDefaultSoundName];
} }
if (has_reply) { [notification_ setHasActionButton:false];
[notification_ setResponsePlaceholder:base::SysUTF16ToNSString(reply_placeholder)];
int i = 0;
for (const auto& action : options.actions) {
if (action.type == base::ASCIIToUTF16("button")) {
[notification_ setHasActionButton:true];
[notification_ setActionButtonTitle:base::SysUTF16ToNSString(action.text)];
action_index_ = i;
}
i++;
}
if (options.has_reply) {
[notification_ setResponsePlaceholder:base::SysUTF16ToNSString(options.reply_placeholder)];
[notification_ setHasReplyButton:true]; [notification_ setHasReplyButton:true];
} }
@ -74,4 +80,9 @@ void CocoaNotification::NotificationReplied(const std::string& reply) {
delegate()->NotificationReplied(reply); delegate()->NotificationReplied(reply);
} }
void CocoaNotification::NotificationButtonClicked() {
if (delegate())
delegate()->NotificationAction(action_index_);
}
} // namespace brightray } // namespace brightray

View file

@ -29,8 +29,10 @@
didActivateNotification:(NSUserNotification *)notif { didActivateNotification:(NSUserNotification *)notif {
auto notification = presenter_->GetNotification(notif); auto notification = presenter_->GetNotification(notif);
if (notification) { if (notification) {
if (notif.activationType == NSUserNotificationActivationTypeReplied){ if (notif.activationType == NSUserNotificationActivationTypeReplied) {
notification->NotificationReplied([notif.response.string UTF8String]); notification->NotificationReplied([notif.response.string UTF8String]);
} else if (notif.activationType == NSUserNotificationActivationTypeActionButtonClicked) {
notification->NotificationButtonClicked();
} else { } else {
notification->NotificationClicked(); notification->NotificationClicked();
} }

View file

@ -6,31 +6,41 @@
#define BRIGHTRAY_BROWSER_NOTIFICATION_H_ #define BRIGHTRAY_BROWSER_NOTIFICATION_H_
#include <string> #include <string>
#include <vector>
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "third_party/skia/include/core/SkBitmap.h"
class GURL; #include "url/gurl.h"
class SkBitmap;
namespace brightray { namespace brightray {
class NotificationDelegate; class NotificationDelegate;
class NotificationPresenter; class NotificationPresenter;
struct NotificationAction {
base::string16 type;
base::string16 text;
};
struct NotificationOptions {
base::string16 title;
base::string16 msg;
std::string tag;
GURL icon_url;
SkBitmap icon;
bool silent;
bool has_reply;
base::string16 reply_placeholder;
std::vector<NotificationAction> actions;
};
class Notification { class Notification {
public: public:
virtual ~Notification(); virtual ~Notification();
// Shows the notification. // Shows the notification.
virtual void Show(const base::string16& title, virtual void Show(const NotificationOptions& options) = 0;
const base::string16& msg,
const std::string& tag,
const GURL& icon_url,
const SkBitmap& icon,
bool silent,
bool has_reply,
const base::string16& reply_placeholder) = 0;
// Closes the notification, this instance will be destroyed after the // Closes the notification, this instance will be destroyed after the
// notification gets closed. // notification gets closed.
virtual void Dismiss() = 0; virtual void Dismiss() = 0;

View file

@ -21,6 +21,7 @@ class NotificationDelegate : public content::DesktopNotificationDelegate {
// Notification was replied to // Notification was replied to
virtual void NotificationReplied(const std::string& reply) {} virtual void NotificationReplied(const std::string& reply) {}
virtual void NotificationAction(int index) {}
}; };
} // namespace brightray } // namespace brightray

View file

@ -29,12 +29,19 @@ void OnWebNotificationAllowed(base::WeakPtr<Notification> notification,
bool allowed) { bool allowed) {
if (!notification) if (!notification)
return; return;
if (allowed) if (allowed) {
notification->Show(data.title, data.body, data.tag, data.icon, icon, brightray::NotificationOptions options;
audio_muted ? true : data.silent, false, options.title = data.title;
base::UTF8ToUTF16("")); options.msg = data.body;
else options.tag = data.tag;
options.icon_url = data.icon;
options.icon = icon;
options.silent = audio_muted ? true : data.silent;
options.has_reply = false;
notification->Show(options);
} else {
notification->Destroy(); notification->Destroy();
}
} }
} // namespace } // namespace

View file

@ -4,54 +4,55 @@
#include <windows.h> #include <windows.h>
#include <string> #include <string>
#include <vector>
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
namespace brightray { namespace brightray {
void Win32Notification::Show( void Win32Notification::Show(const NotificationOptions& options) {
const base::string16& title, const base::string16& msg,
const std::string& tag, const GURL& icon_url,
const SkBitmap& icon, bool silent,
bool has_reply, const base::string16& reply_placeholder) {
auto presenter = static_cast<NotificationPresenterWin7*>(this->presenter()); auto presenter = static_cast<NotificationPresenterWin7*>(this->presenter());
if (!presenter) return; if (!presenter) return;
HBITMAP image = NULL; HBITMAP image = NULL;
if (!icon.drawsNothing()) { if (!options.icon.drawsNothing()) {
if (icon.colorType() == kBGRA_8888_SkColorType) { if (options.icon.colorType() == kBGRA_8888_SkColorType) {
icon.lockPixels(); options.icon.lockPixels();
BITMAPINFOHEADER bmi = { sizeof(BITMAPINFOHEADER) }; BITMAPINFOHEADER bmi = { sizeof(BITMAPINFOHEADER) };
bmi.biWidth = icon.width(); bmi.biWidth = options.icon.width();
bmi.biHeight = -icon.height(); bmi.biHeight = -options.icon.height();
bmi.biPlanes = 1; bmi.biPlanes = 1;
bmi.biBitCount = 32; bmi.biBitCount = 32;
bmi.biCompression = BI_RGB; bmi.biCompression = BI_RGB;
HDC hdcScreen = GetDC(NULL); HDC hdcScreen = GetDC(NULL);
image = CreateDIBitmap(hdcScreen, &bmi, CBM_INIT, icon.getPixels(), image = CreateDIBitmap(hdcScreen, &bmi, CBM_INIT,
options.icon.getPixels(),
reinterpret_cast<BITMAPINFO*>(&bmi), reinterpret_cast<BITMAPINFO*>(&bmi),
DIB_RGB_COLORS); DIB_RGB_COLORS);
ReleaseDC(NULL, hdcScreen); ReleaseDC(NULL, hdcScreen);
icon.unlockPixels(); options.icon.unlockPixels();
} }
} }
Win32Notification* existing = nullptr; Win32Notification* existing = nullptr;
if (!tag.empty()) existing = presenter->GetNotificationObjectByTag(tag); if (!options.tag.empty())
existing = presenter->GetNotificationObjectByTag(options.tag);
if (existing) { if (existing) {
existing->tag_.clear(); existing->tag_.clear();
this->notification_ref_ = std::move(existing->notification_ref_); this->notification_ref_ = std::move(existing->notification_ref_);
this->notification_ref_.Set(title, msg, image); this->notification_ref_.Set(options.title, options.msg, image);
} else { } else {
this->notification_ref_ = presenter->AddNotification(title, msg, image); this->notification_ref_ = presenter->AddNotification(options.title,
options.msg,
image);
} }
this->tag_ = tag; this->tag_ = options.tag;
if (image) DeleteObject(image); if (image) DeleteObject(image);
} }

View file

@ -10,10 +10,7 @@ class Win32Notification : public brightray::Notification {
NotificationPresenterWin7* presenter) : NotificationPresenterWin7* presenter) :
Notification(delegate, presenter) { Notification(delegate, presenter) {
} }
void Show(const base::string16& title, const base::string16& msg, void Show(const NotificationOptions& options) override;
const std::string& tag, const GURL& icon_url,
const SkBitmap& icon, bool silent,
bool has_reply, const base::string16& reply_placeholder) override;
void Dismiss() override; void Dismiss() override;
const DesktopNotificationController::Notification& GetRef() const { const DesktopNotificationController::Notification& GetRef() const {

View file

@ -9,6 +9,7 @@
#include "brightray/browser/win/windows_toast_notification.h" #include "brightray/browser/win/windows_toast_notification.h"
#include <shlobj.h> #include <shlobj.h>
#include <vector>
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "brightray/browser/notification_delegate.h" #include "brightray/browser/notification_delegate.h"
@ -84,20 +85,15 @@ WindowsToastNotification::~WindowsToastNotification() {
} }
} }
void WindowsToastNotification::Show(const base::string16& title, void WindowsToastNotification::Show(const NotificationOptions& options) {
const base::string16& msg,
const std::string& tag,
const GURL& icon_url,
const SkBitmap& icon,
bool silent,
bool has_reply,
const base::string16& reply_placeholder) {
auto presenter_win = static_cast<NotificationPresenterWin*>(presenter()); auto presenter_win = static_cast<NotificationPresenterWin*>(presenter());
std::wstring icon_path = presenter_win->SaveIconToFilesystem(icon, icon_url); std::wstring icon_path = presenter_win->SaveIconToFilesystem(
options.icon,
options.icon_url);
ComPtr<IXmlDocument> toast_xml; ComPtr<IXmlDocument> toast_xml;
if (FAILED(GetToastXml(toast_manager_.Get(), title, msg, icon_path, silent, if (FAILED(GetToastXml(toast_manager_.Get(), options.title, options.msg,
&toast_xml))) { icon_path, options.silent, &toast_xml))) {
NotificationFailed(); NotificationFailed();
return; return;
} }

View file

@ -13,6 +13,7 @@
#include <windows.ui.notifications.h> #include <windows.ui.notifications.h>
#include <wrl/implements.h> #include <wrl/implements.h>
#include <string> #include <string>
#include <vector>
#include "brightray/browser/notification.h" #include "brightray/browser/notification.h"
@ -50,14 +51,7 @@ class WindowsToastNotification : public Notification {
protected: protected:
// Notification: // Notification:
void Show(const base::string16& title, void Show(const NotificationOptions& options) override;
const base::string16& msg,
const std::string& tag,
const GURL& icon_url,
const SkBitmap& icon,
bool silent,
bool has_reply,
const base::string16& reply_placeholder) override;
void Dismiss() override; void Dismiss() override;
private: private:

View file

@ -23,7 +23,7 @@ It creates a new `Notification` with native properties as set by the `options`.
The `Notification` class has the following static methods: The `Notification` class has the following static methods:
#### `BrowserWindow.isSupported()` #### `Notification.isSupported()`
Returns `Boolean` - Whether or not desktop notifications are supported on the current system Returns `Boolean` - Whether or not desktop notifications are supported on the current system
@ -36,6 +36,7 @@ Returns `Boolean` - Whether or not desktop notifications are supported on the cu
* `icon` [NativeImage](native-image.md) - (optional) An icon to use in the notification * `icon` [NativeImage](native-image.md) - (optional) An icon to use in the notification
* `hasReply` Boolean - (optional) Whether or not to add an inline reply option to the notification. _macOS_ * `hasReply` Boolean - (optional) Whether or not to add an inline reply option to the notification. _macOS_
* `replyPlaceholder` String - (optional) The placeholder to write in the inline reply input field. _macOS_ * `replyPlaceholder` String - (optional) The placeholder to write in the inline reply input field. _macOS_
* `actions` [NotificationAction[]](structures/notification-action.md) - Actions to add to the notification. Please read the available actions and limitations in the `NotificationAction` documentation _macOS_
### Instance Events ### Instance Events
@ -83,6 +84,13 @@ Returns:
Emitted when the user clicks the "Reply" button on a notification with `hasReply: true`. Emitted when the user clicks the "Reply" button on a notification with `hasReply: true`.
#### Event: 'action' _macOS_
Returns:
* `event` Event
* `index` Number - The index of the action that was activated
### Instance Methods ### Instance Methods
Objects created with `new Notification` have the following instance methods: Objects created with `new Notification` have the following instance methods:

View file

@ -0,0 +1,20 @@
# NotificationAction Object
* `type` String - The type of action, can be `button`.
* `text` String - (optional) The label for the given action.
## Platform / Action Support
| Action Type | Platform Support | Usage of `text` | Default `text` | Limitations |
|-------------|------------------|-----------------|----------------|-------------|
| `button` | macOS | Used as the label for the button | "Show" | Maximum of one button, if multiple are provided only the last is used. This action is also incomptible with `hasReply` and will be ignored if `hasReply` is `true`. |
### Button support on macOS
In order for extra notification buttons to work on macOS your app must meet the
following criteria.
* App is signed
* App has it's `NSUserNotificationAlertStyle` set to `alert` in the `info.plist`.
If either of these requirements are not met the button simply won't appear.