Open web-dave opened 5 years ago
export class AppComponent {
title = 'pwa-workshop';
constructor(private update: SwUpdate, private push: SwPush) {
this.push
.requestSubscription({
serverPublicKey:
"BCy6k-..."
})
.then(pushSub => console.log(pushSub.toJSON()));
this.push.messages.subscribe((m: { message: string }) =>
this.snackbar.open(JSON.stringify(m))
);
}
}
{
"notification": {
"title": "Angular News",
"body": "Newsletter Available!",
"icon": "assets/icon-72x72.png"
}
}
Example works in CMD
web-push send-notification --payload="{\"notification\":{\"title\":\"Angular News\",\"body\":\"Newsletter Available!\",\"icon\":\"assets/book-monkey.png\"}}" --endpoint="" --key="" --auth="" --vapid-subject="http://127.0.0.1:4488" --vapid-pubkey= --vapid-pvtkey=
SwPush
via DI