神刀安全网

Instapush Proof of Concept

Instapush Proof of Concept

Instapush is a pretty nifty services that acts as a push notifications inbox. I used to be the kind of person who kept push notifications off on all my applications but as time went on I wanted timely information in the form of emails and push notifications more often. For example, I wanted breaking news on the stock market so I can act on that. I also want real time updates on my Internet Of Things home set up. Instapush provided a free and easy way to test my services ideas and I could move them to a dedicated server when needed.

Setting up Instapush is pretty easy. Just get an account on their site, download the mobile app and you’re done. IFTTT offers a number of recipes for Instapush but this blog will focus on writing your own simple integration.

Step one here will be just making sure it works. Instapush provides a simple REST api and you can read about it here. For this project I used a node module that’s a client library for Instapush. It hasn’t been worked on in a while but all the basic functionality is there. If you were to build something lasting I would recommend just interfacing with the REST api directly.

For this proof of concept we’re going to use another module called chokidar which is a file system wrapper for Node.js. We’ll create a simple event emitter that will watch for changes to the file system and on change send what was changed and the file name to my phone in the form of a notification.

“use strict”; let instapush = require(‘instapush’); let configurations = require(’./config.js’).configs; //authorize instapush.settings({ token: configurations.token, id: configurations.id, secret: configurations.secret }); require(‘chokidar’).watch(’.’, {ignoreInitial: true, ignored: /[///]./}).on(‘all’, function(event, path) { instapush.notify({“event”:“fileChangeEvent”,“trackers”:{event: event, path: path}} ,function (err, response){ console.log(response); }); });

原文  http://jowanza.com/post/136136604014/simple-notification-proof-of-concept-with

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Instapush Proof of Concept

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮