web-dave / angular-pwa

0 stars 1 forks source link

SwPush #12

Open web-dave opened 5 years ago

web-dave commented 5 years ago
web-dave commented 5 years ago

app.component.ts


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))
    );
  }
}
web-dave commented 5 years ago

swPush payload:

{
  "notification": {
    "title": "Angular News",
    "body": "Newsletter Available!",
    "icon": "assets/icon-72x72.png"
  }
}
web-dave commented 4 years ago

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=