Giter Site home page Giter Site logo

web-push's Introduction

web-push

Web Push library for Node.js

Supports Firefox 44+ and Chromium/Chrome 42+. Notification with payloads are currently only supported in Firefox (see https://code.google.com/p/chromium/issues/detail?id=486040 for the status in Chromium).

NPM

Build Status dependencies devdependencies

sendNotification(endpoint, TTL, userPublicKey, payload)

Send a Push notification to an endpoint. userPublicKey and payload can be undefined, if you want to send a notification without a message.

  • endpoint is the endpoint URL;
  • TTL is a value in seconds that describes how long a push message is retained by the push service (by default, four weeks);
  • userPublicKey is the public key of the browser;
  • payload is the message to attach to the notification.

The function returns a Promise, resolved when the request to the push service is successful.

setGCMAPIKey(apiKey)

Sets the GCM API key that the library should use in making requests to GCM endpoints (in Chromium/Google Chrome).

  • apiKey is your GCM API key, you can obtain it from the Google Developer Console.

encrypt(userPublicKey, payload)

Encrypts the payload according to the Message Encryption for Web Push standard. (sendNotification will automatically encrypt the payload for you, so if you use sendNotification you don't need to worry about it).

  • userPublicKey is the public key of the browser;
  • payload is the message to attach to the notification.

Examples

The Service Worker Cookbook is full of Web Push examples using the web-push library.

Projects using web-push

web-push's People

Contributors

marco-c avatar zalun avatar

Watchers

James Cloos 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.