-
Notifications
You must be signed in to change notification settings - Fork 566
Service Bus Notification Hubs
This feature will enable developers to send push notifications from their node.js applications simultaneously to hundreds of thousands or mobile clients across IOS and Windows 8. Each message has a tag associated with it. When clients subscribe, they can choose which tags are of interest. Each message published is associated with a tag. Notification Hubs will ensures all messages are broadcasted to subscribers of that tag.
- Template: Template messages are a collection of key/value pairs which are agnostic to a specific push mechanism and which notification hubs will send to all platforms.
- Targeted: Targeted messages target a specific platform / push mechanism.
- Tile: http://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx
- Toast: http://msdn.microsoft.com/en-us/library/windows/apps/hh761494.aspx
- Badge: http://msdn.microsoft.com/en-us/library/windows/apps/hh779719.aspx
Below is a quick snippet for how to use the new api. In the snippet below a new Notification Hub is created, configuring credentials for both apns and wns. Two messages are then sent with different tags to both IOS and Windows 8 devices.
var azure = require('azure');
var credentials = new azure.PushCredentials();
credentials.wns = new azure.WnsCredential(packageSid, clientSecret),
credentials.apns = new azure.ApnsCredential(keydata, certData);
var hub='myhub';
//conn is either a service level or entity level connection string
//hub is the hub to use for the app
var nhs = azure.createNotificationHubService(conn, myhub);
//to create a new hub
nhs.createNotificationHub(name, credentials, function(err, response){..});
//send using wns
var msg = nhs.wns.createTileSquarePeekImageAndText01(language);
msg.image1src = 'http://foobar.com/dog.jpg';
msg.image1alt = 'A dog';
msg.text1 = 'This is a dog';
msg.text2 = 'The dog is nice';
msg.text3 = 'The dog bites';
msg.text4 = 'Beware of dog';
nhs.wns.sendTile('tag', msg, headers, function(err, response) {...});
// send using apns
var msg = nhs.apns.createPayload();
msg.alert = "You got your emails";
msg.badge = 9;
msg.sound = 'bingbong.aiff';
nhs.apns.send('tag2', apnsPayload, function(err, response) {...});
//send using a template
var msg = {}
msg.foo = "foo"
msg.bar = "bar";
nh.send("tag3", msg, function(err, response) {...});
azure.createNotificationHubService(conn, hub)
returns NotificationHubService
- conn - connection string
- hub - hub name
azure.PushCredentails()
Create new push credentials
- wns - WnsCredential
- apns - ApnsCredential
azure.WnsCredential(packageSid, clientSecret)
- packageSid - wns package sid
- clientSecret - wns client secret
- packageSid - wns package sid
- clientSecret - wns client secret
azure.ApnsCredential(keyData, certData)
- keyData - apns key
- certData - apns cert
- keyData - apns key
- certData - apns cert
createNotificationHub(name, credentials)
- name - hub name
- credentials - PushCredentials instance
WnsPush(pushCredentials)
send(tag, xmlString, headers, callback)
- tag - tag for the payload
- xmlString - xml payload for the message
- headers - wns headers
- callback - callback with err and response
sendRaw(tag, stringPayload, headers, callback)
- tag - tag for the payload
- stringPayload - raw payload for the message
- headers - wns headers
- callback - callback with err and response
sendToast(tag, toastPayload, headers, callback)
- tag - tag for the payload
- toastPayload - toast JSON payload
- headers - wns headers
- callback - callback with err and response
sendTile(tag, tilePayload, headers, callback)
- tag - tag for the payload
- tilePayload - tile JSON payload
- headers - wns headers
- callback - callback with err and response
sendBadge(tag, badgePayload, headers, callback)
- tag - tag for the payload
- badgePayload - badge JSON payload
- headers - wns headers
- callback - callback with err and response
createTileSquarePeekImageAndText01(language)
returns: tileSquarePeekImageAndText01
- language - language override for tile
- image1src - Source for the image
- image1alt - alternate for the image
- text1 - first line of text
- text2 - second line of text
- text3 - third line of text
- text4 - fourth line of text.