Skip to main content

NotificationAction Object

  • type string - The type of action, can be button.动作的类型,可以是button
  • text string (optional) - The label for the given action.给定操作的标签。

Platform / Action Support平台/操作支持

Action TypePlatform Support平台支持Usage of texttext的用法Default 默认为textLimitations局限性
buttonmacOSUsed as the label for the button用作按钮的标签"Show" (or a localized string by system default if first of such button, otherwise empty)(如果是第一个这样的button,则系统默认为本地化字符串,否则为空)Only the first one is used. 只使用第一个。If multiple are provided, those beyond the first will be listed as additional actions (displayed when mouse active over the action button). 如果提供了多个动作,则第一个动作之外的动作将被列为附加动作(当鼠标在动作按钮上活动时显示)。Any such action also is incompatible with hasReply and will be ignored if hasReply is true.任何此类操作也与hasReply不兼容,如果hasReplytrue,则将被忽略。

Button support on macOSmacOS上的按钮支持

In order for extra notification buttons to work on macOS your app must meet the following criteria.为了让额外的通知按钮在macOS上工作,您的应用程序必须满足以下标准。

  • App is signed
  • App has it's NSUserNotificationAlertStyle set to alert in the Info.plist.应用程序在Infoplist中将其NSUserNotificationAlertStyle设置为alert

If either of these requirements are not met the button won't appear.如果这两个要求中的任何一个都不满足,按钮将不会出现。