Merge pull request #9837 from electron/notification-actions
Notification actions
This commit is contained in:
commit
0f83180377
16 changed files with 192 additions and 105 deletions
|
@ -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:
|
||||
|
||||
#### `BrowserWindow.isSupported()`
|
||||
#### `Notification.isSupported()`
|
||||
|
||||
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
|
||||
* `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_
|
||||
* `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
|
||||
|
@ -83,6 +84,13 @@ Returns:
|
|||
|
||||
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
|
||||
|
||||
Objects created with `new Notification` have the following instance methods:
|
||||
|
|
20
docs/api/structures/notification-action.md
Normal file
20
docs/api/structures/notification-action.md
Normal 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.
|
Loading…
Add table
Add a link
Reference in a new issue