Git Product home page Git Product logo

push-api-demo's Introduction

push-api-demo

This is an attempt to create a simple chatroom example to demonstrate the Push API. It also illustrates some uses of Service Workers, and how to use Channel Messaging to communicate data between a Service Worker and the main window context.

Current status

At the moment this demo only works on Firefox Nightly. The working parts are:

  • Requesting permission to send notifications/push messages.
  • Registering and activating a service worker to handle the Push/Channel Messages.
  • Subscribing/unsubscribing (to/from) the push sevice.
  • Sending a push message from the server.
  • Sending messages to and from the SW via a message channel.
  • Receiving a push message in the SW via the onpush handler and firing a notification and sending a channel message as a result.

See Using the Push API for more details about how this works.

Still to do

  • Hosting the server somewhere on t'internet so it can be accessed by multiple users (a chatroom is pretty useless with only one user!)
  • Improving the Node server so that it will handle the push messages, AND serve the static files. This is needed for it to start working on Chrome (and Chrome doesn't yet support the PushMessageData either.)

Running the demo

To get it running:

  1. Clone this repo locally (you'll need to install git):

     git clone https://github.com/chrisdavidmills/push-api-demo.git
    
  2. Install NodeJS if you haven't already.

  3. Install dependencies:

     cd push-api-demo
     npm install
    
  4. Run the app:

     node server.js
    
  5. Open the app at https://127.0.0.1:7000/index.html (Note: You will need to add a security exception)

Note: Some of the client-side code in this demo is heavily influenced by Matt Gaunt's excellent examples in Push Notifications on the Open Web. Thanks for the awesome work Matt!

push-api-demo's People

Contributors

chrisdavidmills avatar groovecoder avatar clarkwinkelmann 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.