JSPM

  • Created
  • Published
  • Downloads 229864
  • Score
    100M100P100Q200904F
  • License MPL-2.0

Web Push library for Node.js

Package Exports

  • web-push

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (web-push) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

web-push

Web Push library for Node.js

Supports Firefox 43+ 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;
  • 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.

Projects using web-push