This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

SwPush

Subscribe and listen to push notifications from the Service Worker.

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

Properties

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

Emits the payloads of the received push notification messages.

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>
      
      requestSubscription(options: {
    serverPublicKey: string;
}): Promise<PushSubscription>
    

Parameters

options

Type: { serverPublicKey: string; }.

Returns

Promise<PushSubscription>

unsubscribe(): Promise<void>
      
      unsubscribe(): Promise<void>
    

Parameters

There are no parameters.

Returns

Promise<void>