Coder Social home page Coder Social logo

webpush_sample's Introduction

webpush sample

設定

$ node generate_keypair.js

とすると、キーペアが生成されます。

{ publicKey:
   'BAgiTcYTfsfz9-mMUgHyDP28gxpbz9g4cpl8yhHtB89yRD-1MaKjQ7O3WywoUMQNZ647hS_LPCzwP0r9JJ1fGMw',
  privateKey: '5IJsdvSCbtNxJCfEdkLwUGCMcSrgLEw4yUb6ruqzC6U' }

これらを、pushtest.jsと、static/webpush.jsにそれぞれコピペしてください。

起動

コピペしたら、

http-server static

などでhttp serverを起動します。

ブラウザで表示

ブラウザで表示すると、Push通知を行うかの確認が表示さます。

許可を行うと、Endpoint,Auth,P256dhそれぞれが表示され、「↓コマンドプロンプト、ターミナルにコピペ↓」の下に、ターミナルにコピペするための行が表示されます。

ターミナルにコピペすると、たぶんあなたのブラウザに通知が飛ぶはずです。

詳細

pushtest.jsにペイロードがそのまま書いてあるので、適当に変えてみてください。

ペイロードの扱いは、webpush.jsのshowNotificationにあります。

webpush_sample's People

Contributors

zrelyydereva avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.