Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function insert(item, user, request) {
- // Execute the request and send notifications.
- request.execute({
- success: function() {
- //respond back with success
- request.respond(statusCodes.OK, item);
- //do async tasks
- sendPushNotification(item);
- }
- });
- }
- function sendPushNotification(move) {
- // Create a template-based payload.
- var payload = '{ "alert" : "' + move.playerName + ' just played. It\'s your turn!" }';
- var tag = 'user_id:' + move.otherPlayerId;
- //get the notification hub
- var azure = require('azure');
- var hub = azure.createNotificationHubService('myhub', 'Endpoint=XXXXXXX');
- // Send the move notification to the other user on all platforms.
- hub.send(tag, payload, function(error, outcome){
- if (error) {
- console.error("Error from notification hub on insert move:", error);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement