Blog

"Knowledge has no value unless you use it and share it"

Xamarin and Azure Notification Hubs

 

Xamarin and Microsoft Event in Dublin

Recently, the Azure Dublin user group hosted some of the Microsoft and Xamarin teams in Dublin for a half day conference. Mainly, the Microsoft and Xamarin teams were there to cover some introductory sessions on using xamarin. In addition, they also invited some industry partners to talk about some other technical topics. I presented a quick 15-minute intro on how to use the Azure Notification Hubs platform for sending push notifications to the various platform specific notification services for each of the major mobile platforms.

What is Azure Notification Hubs?

Xamarin Azure Notification Hubs
Azure Notification Hubs

Azure Notification Hubs is the Microsoft Azure scaled-out infrastructure for doing multi-platform push-notifications. It provides you with a single hosted platform. Because of this, you can configure to relay your push notifications to all the major platform specific push notification services.

Currently, Azure Notification Hubs supports sending notifications to

  • Windows Notification Service (WNS) for Windows Phone & Universal Apps on Windows 8 and Window 10
  • The legacy Microsoft Push Notification Service (MPNS) for older Windows Phone 8 apps
  • Apple Push Notification Service (APNS) for Apple Devices such as iPhones and Macs running iOS and OSX
  • Firebase Cloud Messaging (FCM) and Google Cloud Messaging (GCM) for Android devices & chrome apps
  • Baidu Cloud Push for Android in China
  • Amazon Device Messaging (ADM) for Amazon Kindles

 

How to Setup Azure Notification Hubs

Setup can be a little tricky for the respective platforms. In order to configure Google, for example, firstly you’ll need to login to the Google Developer Console. Here you must enable the FireBase/Google Cloud Messaging API, recording your API Key. Secondly, you’ll also need to configure a project under the IAM & Admin Sections. Finally, remember to take note of your Project Number which will be used in your source code.

Alternatively, Apple’s Push Notification Service requires that you generate a CSR which is uploaded to the Apple Developer site.  As a result, that will allow you to create a Certificate. Consequently, this is in turn uploaded to the Azure Notification Hub configuration.

After you have Configured your Azure Notification Hubs

Once you’ve configured the various platform notification services in Azure, you can start pushing notifications out to various subsets of your user base. Notification Hub clients support connecting with Tag configurations. This allows you to dynamically tag your client base by device, demographics, specific user or some other categorisation and then targets those subsets of users

You’ll find some demo code to get you started in our demo repository of on Github and a copy of the presentation slides from the demonstration can be found over on SlideShare.

~Eoin C

VIEW ALL BLOGS