Windows Azure Notification Hubs: Tags and creating a breaking news app
This is part 2 of a 3 part series where we will get to know how Notification Hubs work and why they are a cool feature of Windows Azure.
You can get the source code of the projects in this blog post here: http://github.com/sabbour/breakingnews
In the first part of this blog series, we created a Notification Hub, a server side app to push notifications as well as a Windows 8 app to consume notifications. In this post, we will see a neat feature of Notification Hubs which is Tags.
What are tags?
In the first part, we used the hub to broadcast a notification to all the users on our hub. But what if we want more granular control? Say what if we are building an application like Bing News and we want to push breaking news notifications to only people who are subscribed to a specific category? Tags give you the power to do exactly so.
Tags can act as “interest groups and frees you from maintaining the tag registrations, as the devices themselves handle that. They are simple strings, so they can be anything. Any of the tags below would work:
Building the Breaking News app
The source code of the app is available on GitHub here: http://github.com/sabbour/breakingnews so I won’t be going in details of creating the app, but will highlight the interesting bits of code.
Just like we did in part 1, registrations expire, so you should renew your registration with the Notification Hub upon app launch
Building the Breaking News backend
Regardless of how you build your backend, it can be an MVC website, a Web API, a WCF Service or even a console app, this is how you send the notification. Note that we specified the tag name “sports” when sending the notification. We didn’t have to loop over any records on our database to see who is interested in receiving sports update. It is all handled by the Notification Hub
Download the app from GitHub and play around with it. In the next post, we’ll be covering an exciting feature called Templates. Until then!
Note: This post originally appeared on my MSDN blog at http://blogs.msdn.com/b/africaapps/archive/2013/10/22/w