Skip to content

Instantly share code, notes, and snippets.

@YoungjaeKim
Last active December 18, 2015 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoungjaeKim/5759503 to your computer and use it in GitHub Desktop.
Save YoungjaeKim/5759503 to your computer and use it in GitHub Desktop.
Azure Mobile Service server-side script.
function insert(item, user, request) {
request.execute({
success: function() {
// Write to the response and then send the notification in the background
request.respond();
if(item.platform == "ANDROID") {
push.gcm.send(item.channel, item.text, {
success: function(response) {
console.log('Push sent: ', item.channel, response, 'time: ', new Date());
}, error: function(error) {
console.log('Error sending push: ', item.channel, error, 'time: ', new Date());
}
});
} else if (item.platform == "iOS") {
push.apns.send(item.channel, {
alert: item.alert,
payload: {
inAppMessage: item.text
}
});
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment