GoogleChromeLabs / web-push-codelab

Other
557 stars 293 forks source link

How to send push to browser without companion site ( https://web-push-codelab.appspot.com/)? #19

Closed b1ackRabbit closed 7 years ago

b1ackRabbit commented 7 years ago

In previous docs there was "curl" example with request to https://android.googleapis.com/gcm/send to send push. In current docs only example with this site https://web-push-codelab.appspot.com How can I send push from my web server?

gauntface commented 7 years ago

@maxym83 thanks for raising the issue.

The problem with the previous CURL is that it was for the GCM API and not the Web Push Protocol, which Chrome, Firefox and all future browsers will be using.

The problem with the web push protocol is that it requires encrypting the payload AND it requires creating a signed JSON Web Token (or JWT). This causes issues for CURL usage because the encrypted payload needs to be a stream of bytes (which I don't think can be done) and secondly for the JWT, it's not easy to create.

The web-push-codelab.appspot.com website does all this for you by using a library and that's what we'd strongly recommend web developers to.

From the codelab site: https://codelabs.developers.google.com/codelabs/push-notifications/index.html?index=..%2F..%2Findex#8

The companion app is actually just a node server that is using the web-push library to send messages. It's worthwhile checking out the web-push-libs org on Github to see what libraries are available to send push messages for you (this handles a lot of the nitty gritty details to trigger push messages).

Is there anything we could change that would make this point more obvious? Would adding some text to the 'https://web-push-codelab.appspot.com/' website help?

gauntface commented 7 years ago

In the short term, I've updated https://web-push-codelab.appspot.com/ to include a little info on the libraries to use.

b1ackRabbit commented 7 years ago

Great Thanks!

Probably I was a little inattentive with finding links for libraries. But I think that thanks to a new paragraph "Sending Messages from Your Server" documentions will be more detailed.

z3nix commented 7 years ago

I think it's doing more harm than good to use the example appspot site. There's no real world scenario where that would be useful. If you could update the tutorial with the finished product instead so that people could actually learn the whole thing that would cut a lot of time out for people new to web push.