Repository navigation
Expand file tree
/
Copy pathindex.md
More file actions
42 lines (30 loc) · 1.46 KB
/
Copy pathindex.md
File metadata and controls
42 lines (30 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
title: PushSubscriptionOptions
slug: Web/API/PushSubscriptionOptions
page-type: web-api-interface
browser-compat: api.PushSubscriptionOptions
---
{{APIRef("Push API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The **`PushSubscriptionOptions`** interface of the {{domxref('Push API','','',' ')}} represents the options associated with a push subscription.
The read-only `PushSubscriptionOptions` object is returned by calling {{domxref("PushSubscription.options")}} on a {{domxref("PushSubscription")}}. This interface has no constructor of its own.
## Instance properties
- {{domxref("PushSubscriptionOptions.userVisibleOnly")}} {{ReadOnlyInline}}
- : A boolean value indicating that the returned push
subscription will only be used for messages whose effect is made visible to the user.
- {{domxref("PushSubscriptionOptions.applicationServerKey")}} {{ReadOnlyInline}}
- : A public key your push server will use to send
messages to client apps via a push server.
## Examples
Calling {{domxref("PushSubscription.options")}} on a {{domxref("PushSubscription")}} returns a `PushSubscriptionOptions` object. In the example below this is printed to the console.
```js
navigator.serviceWorker.ready.then((reg) => {
reg.pushManager.getSubscription().then((subscription) => {
const options = subscription.options;
console.log(options); // a PushSubscriptionOptions object
});
});
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}