node-pushover

node.js pushover module for https://pushover.net/api

npm install node-pushover
1 downloads in the last day
24 downloads in the last week
60 downloads in the last month

node-pushover

node.js pushover module for https://pushover.net/api

Install

You can install node-pushover using the Node Package Manager (npm):

npm install node-pushover

Initialization

new Pushover({ token: "APPTOKEN" [, user: "USERKEY"]});

Initializes a Pushover object with the APPTOKEN and optionally a USERKEY . The USERKEY can also be given when sending the messages.

Sending messages

push.send([USERKEY,] title, message [,callback])

Arguments

  • USERKEY: (optional) The USERKEY as given to you by the Pushover API.
  • title: The title for your message
  • message: The content for your message
  • callback(err, res): (optional) A callback function which is called when the message is send.

Example with the USERKEY given at initialisation

var Pushover = require('node-pushover');
var push = new Pushover({
    token: "APPTOKEN",
    user: "USERKEY"
});

// No callback function defined:
push.send("Some title", "Node.js is Cool!! - no callback");

// A callback function is defined:
push.send("Some title", "Node.js is Cool!!", function (err, res){
    if(err){
        console.log("We have an error:");
        console.log(err);
        console.log(err.stack);
    }else{
        console.log("Message send successfully");
        console.log(res);
    }
});

Example with the USERKEY given when the message is send

var Pushover = require('node-pushover');
var push = new Pushover({
    token: "APPTOKEN"
});

// No callback function defined:
push.send("USERKEY", "Some title", "Node.js is Cool!! - no callback");

// A callback function is defined:
push.send("USERKEY", "Some title", "Node.js is Cool!!", function (err, res){
    if(err){
        console.log("We have an error:");
        console.log(err);
        console.log(err.stack);
    }else{
        console.log("Message send successfully");
        console.log(res);
    }
});
npm loves you