We are excited to announce the Batch Direct Send feature for our Basic and Standard tiered customers. This is a batch version of the previously published Direct Send feature, which enabled sends to individual device tokens/channel uris. Since this feature doesn't require devices to be registered with Notification Hubs, customers can now utilize their hubs as scalable push engines at their convenience, simplifying custom device storage and migration scenarios.
The feature is available through REST, and a sample WNS batch direct send payload would look like the following:
// note that the empty line breaks in this payload are mandatory const string payload = @" --simple-boundary Content-type: text/xml Content-Disposition: inline; name=notification--simple-boundary Content-type: application/json Content-Disposition: inline; name=devices ['https://{foo}.notify.windows.com/?token={bar}'] --simple-boundary--"; Hello from Batch Direct Send!
The request in .NET would look similar to the following:
var uri = new Uri("https://my-namespace.servicebus.windows.net/" + myHubName + "/messages/$batch?direct&api-version=2015-08"); var sendRequest = WebRequest.CreateHttp(uri); sendRequest.Method = "POST"; sendRequest.ContentType = @"multipart/mixed; boundary = ""simple-boundary"""; sendRequest.Headers["Authorization"] = GenerateSasToken(uri); sendRequest.Headers["ServiceBusNotification-Format"] = "windows"; sendRequest.Headers["X-WNS-Type"] = "wns/toast";
Try it out and let us know what you think! If you are new, check out our Notification Hubs service and documentations.