npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

push-notify-patched

v1.1.4

Published

Easily send notifications over multiple protocols.

Downloads

3

Readme

push-notify

Build Status Dependency Status devDependency Status

Easily send notifications over several protocols.

Install

npm install push-notify-patched

Usage

Apple Push Notification (APN)

Example

// Create a new APN sender.
var apn = notify.apn({
  key: 'myKey.pem',
  cert: 'myCert.pem'
});

// Send a notification.
apn.send({
  token: 'DEVICE_TOKEN',
  alert: 'Hello world!'
});

Notification

  {string|string[]} token Device token
  ...

Additional fields can be found in node-apn documentation.

Closing connection

APN use a socket and keep it connected, so if we want to gracefully stop a process, you will need to close this connection. A close method is avalaible on the APN sender.

apn.close(function () {
  // the connection is closed
});

Events

transmitted

Emmited when a notification was correctly transmitted to Apple servers. You can find more details in node-apn documentation.

apn.on('transmitted', function (notification, device) {});
transmissionError

Emmited when a error occurs during notfication transmission. You can find more details in node-apn documentation.

apn.on('transmissionError', function (errorCode, notification, device) {});
error

Called when an error occurs during the connection to Apple servers. You can find more details in node-apn documentation.

apn.on('error', function (error) {});

Google Cloud Messaging (GCM)

Example

// Create a new GCM sender.
var gcm = require('push-notify').gcm({
  apiKey: 'GOOGLE_SERVER_API_KEY',
  retries: 1
});

// Send a notification.
gcm.send({
  registrationId: 'REGISTRATION_ID',
  collapseKey: 'COLLAPSE_KEY',
  delayWhileIdle: true,
  timeToLive: 3,
  data: {
    key1: 'message1',
    key2: 'message2'
  }
});

Notification

  {string|string[]} registrationId Device registration id
  {string} collapseKey Collapse key
  {boolean} delayWhileIdle If included, indicates that the message should not be sent immediately if the device is idle. The server will wait for the device to become active, and then only the last message for each collapse_key value will be sent. Optional. The default value is false, and must be a JSON boolean.
  {number} timeToLive How long (in seconds) the message should be kept on GCM 
  {object} data Custom data

Events

transmitted

Emmited when a notification was correctly transmitted to Google servers.

gcm.on('transmitted', function (result, message, registrationId) {});
transmissionError

Emmited when a error occurs during the transmission of the message.

gcm.on('transmissionError', function (error, message, registrationId) {});
updated

Emmited when a registration id must be updated in the database.

gcm.on('updated', function (result, registrationId) {});

Android Cloud to Device Messaging (C2DM)

Example

// Create a new C2DM sender.
var c2dm = require('push-notify').c2dm({
  user: '[email protected]',
  password: 'password',
  domain: 'com.myapp'
});

// Send notification.
c2dm.send({
  registration_id: 'REGISTRATION_ID',
  collapse_key: 'COLLAPSE_KEY',
  'data.titre': 'Hello world!',
  'data.text': 'Is that true?'
});

Notification

  {string|string[]]} registration_id Device registration id
  {string} collapse_key Collapse key
  {string} data.* Custom data field

Events

transmitted

Emmited when a notification was correctly transmitted to Google servers.

c2dm.on('transmitted', function (messageId, payload, registrationId) {});
transmissionError

Emmited when a error occurs during notfication transmission.

c2dm.on('transmissionError', function (error, payload, registrationId) {});
error

Called when an error occurs during the login.

c2dm.on('error', function (error) {});

Windows Push Notification Service (WNS)

Example

// Create a new WNS sender.
var wns = require('push-notify').wns({
  client_id: 'your Package Security Identifier',
  client_secret: 'your Client secret'
});

// Send notification.
wns.send({
  channelURI: 'URI to your application notification channel',
  payload: 'XML containing the notification data',
  type: 'notification type'
});

Notification

  {string} channelURI URI for the device to send the notification to
  {string} payload the XML string containing the notif data
  {string} type notif type. One of: toast, badge, tile, raw
  {object} options an optional options object passed to wns lib (see wns lib)

Events

transmitted

Emmited when a notification was correctly transmitted to Microsoft servers.

wns.on('transmitted', function (result) {});
transmissionError

Emmited when a error occurs during the transmission of the message.

wns.on('transmissionError', function (error) {});

Microsoft Push Notification Service (MPNS)

Example

// Create a new MPNS sender.
var mpns = require('push-notify').mpns();

// Send notification.
mpns.send({
  pushUri: 'DEVICE_PUSH_URI',
  text1: 'Hello world!',
  text2: 'Is that true?'
});

Notification

  {string|string[]} pushUri Device push uri
  {string} text1 Text of the toast (bold)
  {string} text2 Text of the toast (normal)
  {string} param Optional uri parameters

Events

transmitted

Emmited when a notification was correctly transmitted to Microsoft servers.

mpns.on('transmitted', function (result, payload, pushUri) {});
transmissionError

Emmited when a error occurs during the transmission of the message.

mpns.on('transmissionError', function (error, payload, pushUri) {});

Used modules

License

MIT