Learn about the push notification system and how the Azure Notification Hub improves on this system. The demonstration includes provisioning the Notification Hub and sending messages to specific groups using tags.
- [Instructor] Implementing push notifications into your Azure Mobile Apps allows you to send personalized, targeted messages to any user on any platform. Typical push notification uses include sending breaking news alerts, such as Amber Alert. Sending multifactor authentication codes. Sending location-based promotional information, for example, if you happen to be standing outside of your favorite coffee shop, a notification may pop up letting you know that there's a special on today.
Or sending event-related notifications. You'll typically see this a lot at conferences. Session 101 is now starting in room 123. Before we talk about Azure and the Notification Hub, let's first talk about push notification systems in general. Push notifications are platform dependent. That means that Apple has its own push notification system, and it's called the Apple Push Notification Service, or APNS. Androids, it's called Firebase Cloud Messaging, FCM.
And Windows has Windows Notification Services, or WNS. These are all or nothing systems. It means you cannot isolate subscribers. You're sending that same message to everyone. Let's take a look at the workflow for a Platform Notification System. First, the client requests push notifications. Next, the PNS will provide the handle, and that handle will be dependent on the platform, whether it be Apple, Android, or Windows. The client passes a handle to the app back end, where it is then stored.
And when a notification is sent, the back end app connects to the PNS, which in turn sends that notification to the device. This is not a bad system if you're only using one device platform and you need to send the same message to everyone. I think very few of us would fit into that model. To work around the limitations of PNS, we can implement a Notification Hub into our Azure implementation. The Notification Hub supports multiple platforms, and is back-end independent, meaning your back end could be sitting in the cloud or on premise, and it is highly scalable.
Using the Notification Hub simplifies the back-end delivery, because you don't have to worry about notifications for each platform, and you can push to specific users or groups. Let's go ahead and take a look at the work flow when we're using Notification Hub. You'll notice there isn't much difference except all device handles are registered with the hub. Therefore, when a notification is sent, the notification is sent to the Notification Hub first, and then to the appropriate PNS. Let's go ahead, pop into Azure, and show you how we configure this.
I'm in our resource group AzureMobileApp, and we're going to continue to work with the lilmobileapp that we created in a previous lesson. I'm going to go ahead and open the blade for that app. Then I'm going to scroll all the way down to Settings, and then select Push. The first thing we need to do is connect to a Notification Hub. I'm going to go ahead and click Connect. We haven't created that Notification Hub yet, so I'm going to go ahead and do that. Just going to go ahead, create a new Notification Hub. Provide a name for your Notification Hub.
You're going to create a new namespace. And I'm not very creative so I'm going to use lilhub once again. And you'll select a tier based on your needs. Now, a couple things that I would like to point out here. We can see what each tier includes. The one thing that is not listed within our graphics is the SLA. The SLA is not available in the free tier, so if you're looking for an SLA, you'll need to select at least the basic tier to receive that. I'm going to work within that free tier, and then I'm going to go ahead and click OK.
Our Notification Hub is now being deployed and it'll take a few moments. Once your Notification Hub is up and running, we can go ahead and configure push notification services. Here, you would set up the services for each of the services that you're going to use. I'm going to go ahead and click in, let's say, Windows. You'll notice that we'll need to include our package ID and security key. Google will require the API key. Apple requires their specific information, as does Amazon and Baidu. For our demonstration I am not going to set this up.
In a real-world application you would. And I would highly recommend that you refer to the Azure documentation for specifics on how to configure each of these services. I'm going to go ahead and close this. And what I would like to focus in on is how you can send targeted notifications. And we do that using tags. I'm just going to add in a few tags manually, but you could programmatically add these in. Let's go ahead and add in, let's say, weather.
And we can have this set up as Client Requested, therefore the client would say hey, I'd like to have information about the weather, or we can do Automatically Added, which will push it out automatically to that device. In this case I'm just going to go ahead with Client Requested. I'm going to do the same thing for sports. And we'll notice sports is also Client Requested. One thing that you may have noticed that happened under the type, when I clicked on Automatically Added, the authentication was turned on. Therefore, our user had to be authenticated before they get the weather.
I don't think that's really necessary, so I'll go ahead and turn that off. We can also send out notifications using our Azure Active Directory. Let's say we want to be able to send out notifications based on email addresses. Here, I'm going to go ahead and add in email address. You need the dollar sign Azure Active Directory, and then specify your tag. In our example I'm going to use emailaddress. Now you'll notice here that I did have to add the brackets in, and I'm still having an error.
In this case, because I am using Azure Active Directory, I have to automatically add this in, and you'll notice that our authentication method immediately turned to true. Now I can direct messages to specific email addresses from Azure Active Directory. Once you're set up, you can go ahead and click Save. And your push settings have been successfully saved. By using the Mobile App's integration with Notification Hubs, we had the built-in support for the Notification Hub as you saw.
We're able to push out to specific users and groups, as well as devices. And we do all that using tags.
Learn the intermediate-level skills needed to design Azure web and mobile apps for any organization, using the Azure Web Apps and Mobile Apps services. Instructor Sharon Bennett, a Microsoft Certified Solutions Expert, covers securing mobile and web apps with Azure Active Directory, creating WebJobs to script tasks such as queue processing and file maintenance, and extending mobile apps with custom code. Plus, learn how to update, back up, and restore your Azure apps.
As an intermediate-level course, an existing understanding of the Azure platform is required. After completing the training, IT professionals will also be better prepared for Azure certification.
- Create Azure web apps
- Create WebJobs
- Using Traffic Manager
- Adding a CDN to web apps
- Updating, backing up, and restoring Azure Web Apps
- Deploying Azure mobile apps