Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
WIKIPEDIA
/
nodejs
/
Notifications_Imali_API
/
src
/
models
:
MassPusher.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
const async = require("async"); const triggerPush = require("../services/push.service"); class MassPusher{ constructor(listOfTokens,pushData){ this.pushData=pushData; this.success_tokens=[]; this.failure_tokens=[]; this.invokeOperation(listOfTokens); } invokeOperation = (listOfTokens) => { async.each(listOfTokens,this.sendMassPush,(err,info)=>{ if(err) console.log(this.failure_tokens,'error'); else console.log(this.success_tokens,'success'); }); } sendMassPush = (token, callback) =>{ this.pushData.to = token; async.waterfall([ (callback)=>{ triggerPush(this.pushData) .then(()=>{ this.success_tokens.push(token); callback(); }) .catch(()=>{ this.failure_tokens.push(token); callback(); }) } ], function (){ callback(); }) } } module.exports = MassPusher;