1. Home
  2. Training Library
  3. Microsoft Azure
  4. Courses
  5. 70-534 - Design Web and Mobile Apps



Start course


This course covers the Design Azure Web and Mobile Apps part of the 70-534 exam, which is worth 5–10% of the exam. The intent of the course is to help fill in an knowledge gaps that you might have, and help to prepare you for the exam.


Welcome back. In this lesson, we're going to be looking at notifications.

By now, I suspect most of us have seen our fair share of push notifications. An app notifies you that there's a deal on something you're interested in buying, or, if you play mobile games, maybe you've seen a notification letting you know that new content has been released.

Whatever your exposure is, push notifications are a part of modern devices, and since push notifications are on every device, we need to be able to use them, and that means we need to interact with the different platform notification services, or PNS.

Each vendor has its own because they're the gate keeper for the systems that run notifications. This is the default PNS cycle. First, the client app gets a handle from the platform notification service, then the app passes the handle to the backend service for future reference.

The backend server sends a notification to the platform notification service, using the credentials that it fetched in the handle so that it can authenticate with the PNS. The PNS sends a notification to the device. If the handle is expired, then the PNS will reject the notification. In this workflow, our backend service doesn't communicate with the device directly.

It's the job of the PNS to send push notifications. Different platforms notify users in different ways with the user interface. For example, Windows Store and Windows Phone have toast and tiles. Apple iOS has it's dialogs, and so on.

As we mentioned previously, every mobile platform has it's own platform notification service. Windows has the Windows notification, or WNS, Apple has the Apple Push Notification Service, or APN, and they have different interfaces to integrate with them, so not all functions are going to be available to all of these different services.

Having to support them all and understanding the nuances of all of them makes handling notifications a nontrivial task, especially at large scale. This is where notification hub comes into play. Notification Hub is a multi platform, scalable, push notification infrastructure that minimizes the platform-specific code that's necessary to be implemented.

It supports multiple backend programming languages, and it implements multiple delivery patterns, such as broadcast to all users, unicast and multicast to single or groups of users, and segmentation with tags based on area of interest that are specified by the user on their device. And it also supports personalization for specific with templates.

Let's check out an example of how to use Notification Hub. We're going to send a notification to a sample client application. So, we're here in Visual Studio, and we're going to add a new blank universal Windows project. We need to associate our app with the App Store, and there we go, next up, we're going to use NuGet to add a library.

We'll add the Managed Messaging API, and we're going to just click through all the prompts here. Perfect. Okay, now that this is set up, let's drill into our Ce-sharp file here, and let's scroll down, and we're going to add some code to handle the device registration with a notification service.

There we go. And let's add the initialization function. Perfect. And now, let's just clean up some of the missing imports. We just have a few to add. We'll add this. Okay, great, so there we are. Let's come back to this later.

Let's jump into the portal and check things out from the portal's perspective. We're going to create a new Notification Hub, so, as always, we have this blade to fill out. We need a name, and we need a name space, okay, and we need to select a tier. We're going to go to the Free tier and let's just click on create.

Alright, now that it's created, we're going to need to register our application that we'll use to receive our notifications. So, we're going to select Windows, and then we're going to need some additional data from the store where we registered the application.

We have it here in Notepad, so let's just copy and paste these values in, and we're going to click Save. Okay. In the access policies, we have the connection string that we'll need for listening to events.

So let's go back to the application, we're going to edit the code just a bit. We need to give the application name, there we go, and we need to provide the connection strings. Let's paste that in. Great, now, let's fire up the application, and it takes just a second.

And it's a blank application, though, that doesn't matter for this example. Notice that this dialog popped up letting us know that the device has been registered. Now that the device is registered, we're going to go back to the portal, let's close out a couple of these blades, and we're going to use the Test Send tool to send a message.

Okay, let's select our platform and the notification type, and then we need to add some text for our message. And, let's send that. Okay, now that it's sent, you can see that we have a notification in the bottom right. So, everything works and that's how easy it is to basically get started with a demo of Notification Hub.

Okay, that's going to wrap up not only this lesson, but this entire course. The next course in the 75.34 learning path is going to cover management, monitoring, and business continuity. So, whenever you're ready to keep learning I'll see you in the next course.

About the Author

Learning paths15

Ben Lambert is a software engineer and was previously the lead author for DevOps and Microsoft Azure training content at Cloud Academy. His courses and learning paths covered Cloud Ecosystem technologies such as DC/OS, configuration management tools, and containers. As a software engineer, Ben’s experience includes building highly available web and mobile apps. When he’s not building software, he’s hiking, camping, or creating video games.