SwPush

class

Subscribe and listen to push notifications from the Service Worker.

class SwPush {
  messages: Observable<object>
  notificationClicks: Observable<{...}
  subscription: Observable<PushSubscription | null>
  isEnabled: boolean
  requestSubscription(options: { serverPublicKey: string; }): Promise<PushSubscription>
  unsubscribe(): Promise<void>
}

Properties

Property Description
messages: Observable<object> Read-only.

Emits the payloads of the received push notification messages.

notificationClicks: Observable<{ action: string; notification: NotificationOptions & { title: string; }; }> Read-only.

Emits the payloads of the received push notification messages as well as the action the user interacted with. If no action was used the action property will be an empty string ''.

Note that the notification property is not a Notification object but rather a NotificationOptions object that also includes the title of the Notification object.

subscription: Observable<PushSubscription | null> Read-only.

Emits the currently active PushSubscription associated to the Service Worker registration or null if there is no subscription.

isEnabled: boolean Read-only.

True if the Service Worker is enabled (supported by the browser and enabled via ServiceWorkerModule).

Methods

requestSubscription(options: { serverPublicKey: string; }): Promise<PushSubscription>

Parameters
options object
Returns

Promise<PushSubscription>

unsubscribe(): Promise<void>

Parameters

There are no parameters.

Returns

Promise<void>

© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v7.angular.io/api/service-worker/SwPush