Created
June 30, 2015 04:21
-
-
Save korrio/2d9de0e1b8e18b4966de to your computer and use it in GitHub Desktop.
function push
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
//Dep | |
var request = require('request'); | |
push("aaa",400,3,6,"",null); | |
// Chat Notifcation | |
function push( message, messageType, senderId, receiverId, data, all ) { | |
var unreadCount = 0; | |
console.log('asdasd'); | |
// var payload = payload(messageType); | |
var badge = unreadCount++; | |
if(all) { | |
var notificationType = "BROADCAST"; | |
var where = { | |
}; | |
} else { | |
var notificationType = "ONE_TO_ONE"; | |
var where = { | |
user_id: receiverId | |
}; | |
} | |
console.log("######"+receiverId); | |
request.post( | |
{ | |
url:'https://api.parse.com/1/push', | |
headers:{ | |
"X-Parse-Application-Id": "j6DTfeUL6JvI9PunllRInpQbUg3dJLCVNTvaAOfY", | |
"X-Parse-REST-API-Key" : "scpgvOkSsPgF9cEHVH2U8IFYkF3maZV0cOfQmsu0", | |
"Content-Type" : "application/json" | |
}, | |
json:{ | |
data:{ | |
alert: message, | |
title: payload.title, | |
badge: badge, | |
//uri: payload.uri | |
}, | |
where: where | |
} | |
}, | |
function(e,r,body){ | |
//console.log(r); | |
console.log(body); | |
//d.resolve(); | |
} | |
); | |
// | |
//return d.promise; | |
} | |
function payload(messageType) { | |
switch(messageType) { | |
case 1: | |
break; | |
case 2: | |
break; | |
case 3: | |
break; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment