SherClockHolmes / webpush-go

Web Push API Encryption with VAPID support.
MIT License
326 stars 68 forks source link

Simple demo with javascript client side? #14

Closed pwFoo closed 6 years ago

pwFoo commented 6 years ago

Hi @SherClockHolmes ,

is there a simple demo available with client side javascript code? I have js code optimized for web-push-php, but there a some differences (post content handling).

SherClockHolmes commented 6 years ago

Hello @pwFoo,

It's fairly simple, the input just needs to match the Subscription struct: https://github.com/SherClockHolmes/webpush-go/blob/master/webpush.go#L73

Which is modeled after: pushManager.getSubscription(). You can grab the subscription using: https://developer.mozilla.org/en-US/docs/Web/API/PushManager/getSubscription, and then send the subscription to your server.