Last active
December 18, 2015 09:09
-
-
Save YoungjaeKim/5759503 to your computer and use it in GitHub Desktop.
Azure Mobile Service server-side script.
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
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