如何让 macOS 通知保持打开状态并立即显示操作按钮?
How do you make macOS notifications stay open and immediately show action buttons?
当基于 UNNotificationRequest
和 UNNotificationCategory
创建 macOS 通知时,可以制作短暂出现的通知,并带有一个不可见的操作按钮,直到您将鼠标悬停在通知上。
但是,我看到许多通知保持打开状态并带有立即可见的操作按钮(即,无需将鼠标悬停在通知上即可看到按钮)- 例如系统更新可用通知和 MS Office 更新通知.我无法调整通知对象以实现此目的(希望 .destructive
选项会有所作为)。
这是另一种通知吗?或者是否可以调整基于 UNNotificationRequest
的?还是 "regular"(非系统)应用程序根本不可能?
事实上,Ken Thomases 建议的通知样式 "Alerts" 正是我想要的。据推测,可以通过键 NSUserNotificationAlertStyle
(apple docs) 在您的应用程序 Info.plist
中将其设置为默认值:
NSUserNotificationAlertStyle (String - macOS) specifies the
notification style the app should use. The default value, banner, is
recommended; most apps should not need to use the alert style.
但是,从 2020 年开始这似乎不起作用 - 事实上有几份报告称这在网上不起作用。
此外,网上有几篇帖子指出,这本来是不可能在应用程序内完成的。所以我放弃了,想知道为什么 Microsoft Office 更新程序能够使用警报样式呈现 - 我 100% 确定我从未在通知设置中更改它的呈现样式。
当基于 UNNotificationRequest
和 UNNotificationCategory
创建 macOS 通知时,可以制作短暂出现的通知,并带有一个不可见的操作按钮,直到您将鼠标悬停在通知上。
但是,我看到许多通知保持打开状态并带有立即可见的操作按钮(即,无需将鼠标悬停在通知上即可看到按钮)- 例如系统更新可用通知和 MS Office 更新通知.我无法调整通知对象以实现此目的(希望 .destructive
选项会有所作为)。
这是另一种通知吗?或者是否可以调整基于 UNNotificationRequest
的?还是 "regular"(非系统)应用程序根本不可能?
事实上,Ken Thomases 建议的通知样式 "Alerts" 正是我想要的。据推测,可以通过键 NSUserNotificationAlertStyle
(apple docs) 在您的应用程序 Info.plist
中将其设置为默认值:
NSUserNotificationAlertStyle (String - macOS) specifies the notification style the app should use. The default value, banner, is recommended; most apps should not need to use the alert style.
但是,从 2020 年开始这似乎不起作用 - 事实上有几份报告称这在网上不起作用。
此外,网上有几篇帖子指出,这本来是不可能在应用程序内完成的。所以我放弃了,想知道为什么 Microsoft Office 更新程序能够使用警报样式呈现 - 我 100% 确定我从未在通知设置中更改它的呈现样式。