Skip to content

Instantly share code, notes, and snippets.

@ChrisRisner
Created November 18, 2012 02:15
Show Gist options
  • Save ChrisRisner/4102931 to your computer and use it in GitHub Desktop.
Save ChrisRisner/4102931 to your computer and use it in GitHub Desktop.
1devday
function insert(item, user, request) {
item.userId = user.userId;
request.execute({
success: function(){
request.respond();
sendNotifications(item);
},
error: function(err){
request.respond(500, "Error");
}
});
}
function sendNotifications(item){
var tokenTable = tables.getTable('ApnsToken');
tokenTable.read({
success: function(tokens){
tokens.forEach(function(token){
push.apns.send(token.token, {
alert: "new item: " + item.text
}
, {
success: function(response){
console.log(response);
},
error: function(err){
console.error(err);
}
});
});
}
});
}
function read(query, user, request) {
query.where({userId : user.userId});
request.execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment