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

SwPush

npm Package @angular/service-worker
Module import { SwPush } from '@angular/service-worker';
Source service-worker/src/push.ts

Overview

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

Description

Subscribe and listen to push notifications from the Service Worker.

Constructor

      
      constructor(sw: NgswCommChannel)
    

Members

      
      get messages: Observable<object>
    

      
      get subscription: Observable<PushSubscription | null>
    

      
      get isEnabled: boolean
    

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


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

      
      unsubscribe(): Promise<void>
    

Annotations

      
      @Injectable()