Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pushy

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pushy

The official Node.js package for sending push notifications with Pushy.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

pushy-node

npm version

The official Node.js package for sending push notifications with Pushy.

Pushy is the most reliable push notification gateway, perfect for real-time, mission-critical applications.

Note: If you don't have an existing Node.js project, consider using our sample Node.js API project as a starting point to make things easier for you.

Usage

First, install the package using npm:

npm install pushy-node --save

Then, use the following sample code to send a push notification to target devices:

var Pushy = require('pushy-node');

// Plug in your Secret API Key
// Get it here: https://dashboard.pushy.me/
var pushyAPI = new Pushy('SECRET_API_KEY');

// Set push payload data to deliver to device(s)
var data = {
    message: 'Hello World!'
};

// Insert target device token(s) here
var tokens = ['DEVICE_TOKEN'];

// Set optional push notification options (such as TTL)
var options = {
    // Set the notification to expire if not delivered within 30 seconds
    time_to_live: 30
};

// Send push notification via the Push Notifications API
// https://pushy.me/docs/api/send-notifications
pushyAPI.sendPushNotification(data, tokens, options, function (err, id) {
    // Log errors to console
    if (err) {
        return console.log('Fatal Error', err);
    }
    
    // Log success
    console.log('Push sent successfully! (ID: ' + id + ')');
});

Alternatively, send the notification using promises:

pushyAPI.sendPushNotification(data, tokens, options)
    .then(function (id) {
        // Log success
        console.log('Push sent successfully! (ID: ' + id + ')');
    }).catch(function (err) {
        // Log errors to console
        return console.log(err);
    });

Make sure to replace SECRET_API_KEY with your app's Secret API Key listed in the Dashboard.

License

Apache 2.0

FAQs

Package last updated on 26 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc