4.11.1 • Published 9 months ago

@ng-web-apis/notification v4.11.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

ng-web-apis logo Notification API for Angular

npm version npm bundle size codecov

This is a library for declarative use of Notification API with Angular.

Install

npm i @ng-web-apis/notification

Usage

  1. Import the NotificationService into your Angular component or service where you want to use it.
import {NotificationService} from '@ng-web-apis/notification';
  1. Inject the NotificationService into your component's constructor or with inject (Angular 14+).
// in constructor
constructor(private notificationAPIService: NotificationService) {}

// via inject
notificationAPIService = inject(NotificationService);
  1. Use the requestPermission and open methods to request permission and open a notification.
this.notificationAPIService
  .requestPermission()
  .pipe(
    filter((permission) => permission === 'granted'),
    switchMap(() =>
      this.notificationAPIService.open('Hello world!', {
        body: 'This is a notification',
        requireInteraction: true,
      }),
    ),
  )
  .subscribe();

Demo

You can try online demo here

See also

Other Web APIs for Angular by @ng-web-apis

4.11.0

9 months ago

4.11.1

9 months ago

4.9.0

10 months ago

4.8.0

10 months ago

4.6.5

10 months ago

4.7.0

10 months ago

4.10.1

10 months ago

4.10.2

10 months ago

4.10.0

10 months ago

4.6.4

10 months ago

4.6.3

10 months ago

4.6.2

10 months ago

4.6.1

10 months ago

4.6.0

10 months ago