Skip to content

Commit

Permalink
Notification.silent: Add Firefox 132 rel note, and improve document…
Browse files Browse the repository at this point in the history
…ation (#36191)

* Add Firefox 132 rel note, and improve silent documentation

* Comma fixes
  • Loading branch information
chrisdavidmills authored Oct 9, 2024
1 parent 42976d3 commit 79f5e2c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
2 changes: 2 additions & 0 deletions files/en-us/mozilla/firefox/releases/132/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ This article provides information about the changes in Firefox 132 that affect d

### APIs

- The {{domxref("Notification.silent")}} property is now supported, which controls whether system notifications should be silent. When `silent: true` is specified in the {{domxref("Notification.Notification", "Notification()")}} constructor, the resulting system notification is issued without accompanying sounds or vibrations, regardless of device settings ([Firefox bug 1809028](https://bugzil.la/1809028)).

#### DOM

#### Media, WebRTC, and Web Audio
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/notification/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ _Also inherits properties from its parent interface, {{domxref("EventTarget")}}_
- {{domxref("Notification.requireInteraction")}} {{ReadOnlyInline}}
- : A boolean value indicating that a notification should remain active until the user clicks or dismisses it, rather than closing automatically.
- {{domxref("Notification.silent")}} {{ReadOnlyInline}}
- : Specifies whether the notification should be silent — i.e., no sounds or vibrations should be issued, regardless of the device settings.
- : Specifies whether the notification should be silent — i.e., no sounds or vibrations should be issued regardless of the device settings.
- {{domxref("Notification.tag")}} {{ReadOnlyInline}}
- : The ID of the notification (if any) as specified in the constructor's `options` parameter.
- {{domxref("Notification.timestamp")}} {{ReadOnlyInline}} {{Experimental_Inline}}
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/notification/notification/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ new Notification(title, options)
- `requireInteraction` {{optional_inline}}
- : Indicates that a notification should remain active until the user clicks or dismisses it, rather than closing automatically. The default value is `false`.
- `silent` {{optional_inline}}
- : A boolean value specifying whether the notification is silent (no sounds or vibrations issued), regardless of the device settings. The default, `null`, means to respect device defaults. If `true`, then `vibrate` must not be present.
- : A boolean value specifying whether the notification should be silent, i.e., no sounds or vibrations should be issued regardless of the device settings. If set to `true`, the notification is silent; if set to `null` (the default value), the device's default settings are respected.
- `tag` {{optional_inline}}
- : A string representing an identifying tag for the notification. The default is the empty string.
- `timestamp` {{optional_inline}}
Expand Down
35 changes: 26 additions & 9 deletions files/en-us/web/api/notification/silent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,46 @@ browser-compat: api.Notification.silent

The **`silent`** read-only property of the
{{domxref("Notification")}} interface specifies whether the notification should be
silent, i.e., no sounds or vibrations should be issued, regardless of the device
settings. This is specified in the `silent` option of the
silent, i.e., no sounds or vibrations should be issued regardless of the device
settings. This is controlled via the `silent` option of the
{{domxref("Notification.Notification","Notification()")}} constructor.

## Value

A boolean value or `null`. If `true`, the notification is silent; if `null`, the device's default settings are respected.
A boolean value or `null`. If set to `true`, the notification is silent; if set to `null` (the default value), the device's default settings are respected.

## Examples

The following snippet is intended to fire a silent notification; a simple
`options` object is created, and then the notification is fired using the
{{DOMxRef("Notification.Notification","Notification()")}} constructor.
The following snippet fires a silent notification. An
`options` object is created, and the notification is fired in response to a button click using the
{{DOMxRef("Notification.Notification","Notification()")}} constructor. The code also includes rudimentary permissions handling, requesting permission from the user to fire notifications if it has not already been granted.

```js
const btn = document.querySelector("button");

const options = {
body: "Your code submission has received 3 new review comments.",
body: "No annoying pings or vibrations?",
silent: true,
};

const n = new Notification("New review activity", options);
function requestSilentNotification() {
const n = new Notification("Silent notification", options);
console.log(n.silent); // should return true
}

console.log(n.silent); // true
btn.addEventListener("click", () => {
if (Notification.permission === "granted") {
requestSilentNotification();
} else {
Notification.requestPermission().then((permission) => {
if (permission === "granted") {
requestSilentNotification();
} else {
console.log("Notification permission was not granted");
}
});
}
});
```

## Specifications
Expand Down

0 comments on commit 79f5e2c

Please sign in to comment.