docs: update notifications tutorial (#37602)
* docs: update notifications tutorial * delete unused assets
This commit is contained in:
parent
5023b49713
commit
52481bc923
4 changed files with 107 additions and 92 deletions
|
@ -4,9 +4,12 @@
|
|||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
## Using in the renderer process
|
||||
:::info Renderer process notifications
|
||||
|
||||
If you want to show Notifications from a renderer process you should use the [HTML5 Notification API](../tutorial/notifications.md)
|
||||
If you want to show notifications from a renderer process you should use the
|
||||
[web Notifications API](../tutorial/notifications.md)
|
||||
|
||||
:::
|
||||
|
||||
## Class: Notification
|
||||
|
||||
|
@ -29,10 +32,10 @@ Returns `boolean` - Whether or not desktop notifications are supported on the cu
|
|||
### `new Notification([options])`
|
||||
|
||||
* `options` Object (optional)
|
||||
* `title` string (optional) - A title for the notification, which will be shown at the top of the notification window when it is shown.
|
||||
* `title` string (optional) - A title for the notification, which will be displayed at the top of the notification window when it is shown.
|
||||
* `subtitle` string (optional) _macOS_ - A subtitle for the notification, which will be displayed below the title.
|
||||
* `body` string (optional) - The body text of the notification, which will be displayed below the title or subtitle.
|
||||
* `silent` boolean (optional) - Whether or not to emit an OS notification noise when showing the notification.
|
||||
* `silent` boolean (optional) - Whether or not to suppress the OS notification noise when showing the notification.
|
||||
* `icon` (string | [NativeImage](native-image.md)) (optional) - An icon to use in the notification.
|
||||
* `hasReply` boolean (optional) _macOS_ - Whether or not to add an inline reply option to the notification.
|
||||
* `timeoutType` string (optional) _Linux_ _Windows_ - The timeout duration of the notification. Can be 'default' or 'never'.
|
||||
|
@ -47,8 +50,11 @@ Returns `boolean` - Whether or not desktop notifications are supported on the cu
|
|||
|
||||
Objects created with `new Notification` emit the following events:
|
||||
|
||||
**Note:** Some events are only available on specific operating systems and are
|
||||
labeled as such.
|
||||
:::info
|
||||
|
||||
Some events are only available on specific operating systems and are labeled as such.
|
||||
|
||||
:::
|
||||
|
||||
#### Event: 'show'
|
||||
|
||||
|
@ -56,7 +62,7 @@ Returns:
|
|||
|
||||
* `event` Event
|
||||
|
||||
Emitted when the notification is shown to the user, note this could be fired
|
||||
Emitted when the notification is shown to the user. Note that this event can be fired
|
||||
multiple times as a notification can be shown multiple times through the
|
||||
`show()` method.
|
||||
|
||||
|
@ -106,14 +112,13 @@ Emitted when an error is encountered while creating and showing the native notif
|
|||
|
||||
### Instance Methods
|
||||
|
||||
Objects created with `new Notification` have the following instance methods:
|
||||
Objects created with the `new Notification()` constructor have the following instance methods:
|
||||
|
||||
#### `notification.show()`
|
||||
|
||||
Immediately shows the notification to the user, please note this means unlike the
|
||||
HTML5 Notification implementation, instantiating a `new Notification` does
|
||||
not immediately show it to the user, you need to call this method before the OS
|
||||
will display it.
|
||||
Immediately shows the notification to the user. Unlike the web notification API,
|
||||
instantiating a `new Notification()` does not immediately show it to the user. Instead, you need to
|
||||
call this method before the OS will display it.
|
||||
|
||||
If the notification has been shown before, this method will dismiss the previously
|
||||
shown notification and create a new one with identical properties.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue