Socket
Book a DemoInstallSign in
Socket

@ng-web-apis/notification

Package Overview
Dependencies
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ng-web-apis/notification

A library for declarative use of Notification API with Angular

latest
Source
npmnpm
Version
4.12.0
Version published
Maintainers
4
Created
Source

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

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

// via inject
notificationAPIService = inject(NotificationService);
  • 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

Keywords

angular

FAQs

Package last updated on 31 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts