Last active
August 29, 2015 14:01
-
-
Save sedouard/cfea7abb6d5df880e194 to your computer and use it in GitHub Desktop.
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
var azure = require('azure'); | |
//call POST https://<service-name>.azure-mobile.net/api/<endpoint name> with the tag you want in the query parameter | |
exports.post = function(request, response) { | |
var hub = azure.createNotificationHubService("crossplatpushdemohub", "Endpoint=sb://crossplatpushdemohub-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=AGeyP6352Hg585VK88XkjrXwKy37st/dp4xVGrpdyO4="); | |
var sendMessage = function(tag, message){ | |
//note that even though the Hub will take care of talking to each service | |
//you must provide a platform-specific formatted message | |
//send to tagged ios devices | |
hub.apns.send(request.query.tag, {alert:message}, function(error){ | |
if(error){ | |
console.error(error); | |
} | |
}); | |
//send to tagged andriod devices | |
hub.gcm.send(request.query.tag, {data:{ message: message }}, function(error){ | |
if(error){ | |
console.error(error); | |
} | |
}); | |
response.send(statusCodes.OK, { message : 'Sent Notification!' }); | |
} | |
sendMessage(request.query.tags, request.query.message); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment