A library for declarative use of Notification API with Angular
npm install @ng-web-apis/notification


This is a library for declarative use of
Notification API with Angular.
``bash`
npm i @ng-web-apis/notification
1. Import the WaNotificationService into your Angular component or service where you want to use it.
`ts`
import {WaNotificationService} from '@ng-web-apis/notification';
2. Inject the WaNotificationService into your component.
`ts`
// via inject
notificationAPIService = inject(WaNotificationService);
3. Use the requestPermission and open methods to request permission and open a notification.
`ts``
this.notificationAPIService
.requestPermission()
.pipe(
filter((permission) => permission === 'granted'),
switchMap(() =>
this.notificationAPIService.open('Hello world!', {
body: 'This is a notification',
requireInteraction: true,
}),
),
)
.subscribe();
You can try online demo here
Other Web APIs for Angular by
@ng-web-apis