Azure Service Bus Notification Hub for iOS + Bonus Xamarin Binding!

UPDATE: Xamarin now has a component in their component store for Azure Messaging, that uses the Notification Hubs described in this blogpost.

Recently I’ve been working with Edwin van Wijk on the brand new Azure Service Bus Notification Hub by Microsoft. It’s a unified messaging hub for delivering push notifications to mobile devices. It’s became GA in August 2013, and now supports all major mobile platforms, including iOS and Android.

Here’s a video of our presentation on this topic, at our weekly tech meetup at Info Support HQ (it’s in Dutch):

The service is quite nice, and is a cloud based contenter to products like PushSharp. You won’t need custom hosts for the integration, which is a benefit over PushSharp and the likes. However, in its current (Preview) version, it doesn’t support nearly as many platforms as PushSharp.

The Notification Hub builds upon the Azure Service Bus infrastructure for relaying messages in a massively scalable way. This means that it also leverages Service Bus’s topics and subscriptions feature for easily grouping messages using Tags. A nice way to filter messages and distinguish groups.

Edwin and I did a session on this. You can find the slides here. The slides are in Dutch by the way.

For iOS, Microsoft has released a native Objective-C library as part of their Azure SDK. There’s a tutorial on MSDN that nicely describes the steps you need to take to consume the library in XCode.

In order to test it, you’ll need to set up quite a lot of prerequisites, including a Windows Azure Service Bus instance, a Notification Hub, Apple AppID and an APNS certificate. A bit finicky to set up, but once it runs, it works nicely.

Xamarin.iOS binding
It’s quite logical for Microsoft to release an Objective-C library at first. Still, I felt a bit dissatisfied having to write my app in Objective-C. I have been wanting to experiment a bit more with creating a C# binding to Objective-C libraries, so I’ve decided to make one available for this library.

I have a working version up on GitHub, which includes a sample. It’s based on the latest API version – you’ll need a Notification Hub created after April 2013 for it to work. You’ll also need to setup your own certificates and fill in the Service Bus namespace, Notification Hub name and Shared Access Secret Listen key.

Basically, you’ll use the library in the RegisteredForRemoteNotifications method on your AppDelegate class. I have a write-up on that in an older blogpost here.

The current binding is a basic one. Completion handlers are mapped to delegates, and I think some of the type mappings could be more C# friendly. I’d also like to make it async/await friendly but I’ll have to experiment with that a bit more.

I’d love to hear your feedback on this!

[UPDATE August 13th, 2013: I’ve updated the Xamarin.iOS binding to the GA version!]