forked from pushbots/instapush-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
39 lines (35 loc) · 1.01 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var instapush = require('./lib/index.js');
//authorize
instapush.settings({
token: 'TOKEN',
id:'ID',
secret:'SECRET',
});
//basic usage for any method
instapush.request('GET','/apps/list' ,function (err, response){
console.log(response);
});
//send a push notification triggered with the search event
instapush.notify({"event":"search","trackers":{"term":"api"}} ,function (err, response){
console.log(response);
});
//list all events for the app, using the id and secret
instapush.listEvents(function (err, response){
console.log(response);
});
//list all apps for a user using user token
instapush.listApps(function (err, response){
console.log(response);
});
//adding a new event to an application
data = {"title":"signup",
"trackers":["email","count"],
"message":"{email} signed up ({count})"
};
instapush.addEvent(data,function (err, response){
console.log(response);
});
//adding a new app to user using user token.
instapush.addApp({"title":"NodeJSAPP"},function (err, response){
console.log(response);
});