
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
ngx-push-notifications
Advanced tools
Push notifications for PWA using Service Workers in Angular
Official Push API documentation is here Mozilla developer network.
and here Google Developers
To install this library, run:
npm install ngx-push-notifications --save
Import the PushNotificationService
into your AppModule
import { PushNotificationService } from 'ngx-push-notifications';
@NgModule({
declarations: [...],
imports: [...],
providers: [PushNotificationService],
bootstrap: [...]
})
export class AppModule { }
...
Now import the PushNotificationsService
and PushNotificationOptions
in your component where you want to use it:
import { PushNotificationOptions, PushNotificationService } from 'ngx-push-notifications';
...
constructor(private _pushNotificationService: PushNotificationService) { }
...
To request permission from the user to display push notifications call the requestPermission()
method of PushNotificationsService
.
ngOnInit() {
this._pushNotificationService.requestPermission();
}
You can also check if permission was already granted previously.
const isGranted = this._pushNotificationService.isPermissionGranted;
Example:
myFunction() {
const title = 'Hello';
const options = new PushNotificationOptions();
options.body = 'Native Push Notification';
this._pushNotificationService.create(title, options).subscribe((notif) => {
if (notif.event.type === 'show') {
console.log('onshow');
setTimeout(() => {
notif.notification.close();
}, 3000);
}
if (notif.event.type === 'click') {
console.log('click');
notif.notification.close();
}
if (notif.event.type === 'close') {
console.log('close');
}
},
(err) => {
console.log(err);
});
}
A notification will raise events at each stage which you can handle.
Options that can be passed to the options parameter:
export declare class PushNotificationOptions {
body: string;
icon: string;
sound: string;
data: any;
tag: string;
dir: NotificationDirection;
lang: string;
renotify: boolean;
sticky: boolean;
vibrate: Array<number>;
noscreen: boolean;
silent: boolean;
}
Options are the same as the Notification API in Mozilla developer network.
Your feedback is important
FAQs
Push notifications for PWA using Service Workers in Angular
The npm package ngx-push-notifications receives a total of 96 weekly downloads. As such, ngx-push-notifications popularity was classified as not popular.
We found that ngx-push-notifications demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.