node-notifier

One of the most common things while developing API’s or web applications is that you want to notify your users about some new stuff. node-notifier is a simple module that makes notifications easy.

Installation

$ npm install notifier

or include it in package.json

Usage

For email notifications, you have to use (jade) templates to write the email body. By default it uses postmarkapp to send emails (in the upcoming versions you’ll be able to configure this). If you plan to not use jade, you can override the processTemplate method to use templating language of your choice.

varnotifier=newNotifier({APN:false,// apple push notificationsemail:true,actions:['comment','like'],// should be the name of the template filestplPath:require('path').resolve(__dirname,'./templates'),// path to the directory where all the templates residepostmarkKey:'POSTMARK_KEY'});varcomment={to:'Tom',from:'Harry'};varoptions={to:'tom@madhums.me',subject:'Harry says Hi to you',from:'harry@madhums.me',locals:comment// should be the object containing the attributes used in the template};notifier.send('comment',options,function(err){if(err)returnconsole.log(err);console.log('Successfully sent Notifiaction!');});

For APN (apple push notifications), notifier uses parse-sdk. Set the APN key to true and provide parseAPI appId and app secret. You can either do

varnotifier=newNotifier({APN:true,// apple push notificationsactions:['comment','like'],// should be the name of the templatesparseAppId:'APP_ID',parseApiKey:'MASTER_KEY',parseChannels:['USER_5093a266180b779762000005']});

Resources:

Hi, I am Madhu, I am a Freelance Full stack Programmer and a UX Designer currently living in the Netherlands. I love travelling and people. I like to work on stuff that creates a positive impact on our society.