Skip to main content

Azure Notification Hub (Day 23 of 31)

List of all posts from this series: http://vunvulearadu.blogspot.ro/2014/11/azure-blog-post-marathon-is-ready-to.html

Short Description
Azure Notification Hub allow us to send notifications from any backend (hosted on cloud or on-premises) to our devices/clients.
I don’t know I you had the opportunity to work on a system that needs to work with different PNS providers (iOS, Android, WP), but managing all different platforms, tokens, trigger notification for each device of group of devices can be a time consuming task not only for developers but also for the person that trigger the notification.
For use cases like this Azure Notification Hub can become our best friend.


Main Features
Platform Agnostic
We can send notifications to any kind of device or system. From Android to iOS, to desktop application or even kindles.
Focus on content
Azure Notification Hubs enable us to focus on the content that we want to send to our applications and not on the notification system platform that we use. In this way we don’t care about the infrastructure and format of the notification that is send.
Scalable
With only one API call we can trigger a notification that is send to millions of devices across the glob.
Telemetry
This service has the capability to track notification. In this way, we ca know what is the status of each notification that was send, how many devices received it and so on.
Cross Platform
It has support for multiple platforms like iOS, Android, WP, desktop and even kindle.
No Integration development
There is no need to write custom code that integrates each PNS provider.
 Xamarin Support
There is full support for Xamarin cross-platform applications.
Support for Registration from Device or from Backend
Both registration mechanism are supported in the current architecture of Azure Notification Hub. It is recommended to use the second one, because it allow us to update the tags (user subscriptions) on all devices that are registered for that user, not only on devices that are online.
Tags
To be able to send a notification to a specific device, tags needs to be used. Each device can have associated one or more tags. When a notification is send it is send to a specific tag. All devices that are registered with that specific tag will receive the notification.
We can see tags as a mechanism to group devices, but in in the same time we can have a tag that unique identify a registered device.
Tag Expression
We can send a notification that target a combination of tags. For this use causes we can define an expression based on AND, OR and NOT. For example we can send a notification for all people from UK and Germany that are interested to receives notification about Christmas.
(( UK || Germany ) && Christmas)

Device Targeting  
As we can saw above when we send a notification we can target a specific tag or a tag expression. There 3 ways to target a notification:

  • Tags
  • Tag Expression
  • Broadcast (all devices that are registered in Notification Hub will receive the notification)

Templates
Because each device has a different notification platform with different functionalities, we need to a mechanism to specify different content based on device type and features. For example we may want to send a graphical image as a notification for devices that support this.
Templates allow us to specify a parameterized template for each device type. In this way the final content that will be received by a specific device will contain content that is supported by him.
This is a very powerful feature that you should use. More information about this can be found here http://msdn.microsoft.com/en-us/library/azure/dn530748.aspx
Security
The base mechanism that is used to manage access of different systems (that produce and send notification over the wire) is Shared Access Signature (SAS). Using SAS we can manage access of each system.
SAS is based on a token that can specify what kind of claims has each system. Below you can find the list of claims:

  • Listen (Create, Read, Delete Registrations)
  • Send (Send Notifications)
  • Manage (Create, Read, Update, Delete Notification Hubs, Read registration by tag)

Scheduling
We are allowed to register a notification that will be send at a specific time in future. In this way we can send notifications to our clients at a specific time.
Import/Export
We can export or import a bulk of registrations. In this way we can automatically manage the devices that are registered.

Limitations 
There are some limitation related to notification size, tag name and so on, but this are not real limitations.
For the Free and Basic tier there is also a limitation at the number of tags, devices registered with the same tag and so on. All this limitation are removed if you are using Standard tier that allow us to nock yourself out.

Applicable Use Cases 
Below you can find some use cases when I would use Azure Notification Hub
Discounts notification
If you have a store and every day or week you have special discounts, that you can use this notification system to notify users about special offers and discounts. Combined with scheduler support, you can setup your discounts offers in advance.
Breaking news
For application that share content and news to clients, a system like this can be used with success to send breaking news notification to users.
Alerts
Notification Hub can be used by applications that needs to send alerts to users when something is happening in their region. For example alerts can be used to send notifications when the risk level in a specific region was changed or a natural calamity will happen.


Code Sample 
// Send notification at a specific time
Notification notification = new AppleNotification("{\"aps\":{\"alert\":\"Special discount ony for you!\"}}");
var scheduled = await hub.ScheduleNotificationAsync(notification, new DateTime(2014, 12, 24, 10, 0, 0));

Pros and Cons 
Pros

  • Scalable
  • Template support allow us to use features that are specific for each platform
  • Simple to use
  • Telemetry support
  • Free tier is great for start-ups and is FREE.

Cons
-

Pricing
When you calculate the cost of Azure Notification Hub you should take into account the following:

  • Number of notification that will be send per month
  • Number of tags
  • Number of devices registered with the same tag
  • Scheduler support


Conclusion
Azure Notification Hub is design to any type of application and customer. From the small one that has a limited budget to the large one that needs strong SLAs and features like import/export. This is a service that you should keep in mind and use it when you need to send notifications.

Comments

Popular posts from this blog

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

[Post-Event] Codecamp Conference Cluj-Napoca - Nov 19, 2016

Last day I was invited to another Codecamp Conference, that took place in Cluj-Napoca. Like other Codecamp Conferences, the event was very big, with more than 1.000 participants and 70 sessions. There were 10 tracks in parallel, so it was pretty hard to decide at  what session you want to join.
It was great to join this conference and I hope that you discovered something new during the conference.
At this event I talked about Azure IoT Hub and how we can use it to connect devices from the field. I had a lot of demos using Raspberry PI 3 and Simplelink SensorTag. Most of the samples were written in C++ and Node.JS and people were impressed that even if we are using Microsoft technologies, we are not limited to C# and .NET. World and Microsoft are changing so fast. Just looking and Azure IoT Hub and new features that were launched and I'm pressed (Jobs, Methods, Device Twin).
On backend my demos covered Stream Analytics, Event Hub, Azure Object Storage and DocumentDB.

Title:
What abo…