Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send notifications to individual users using Azure Notification Hub

I am creating a Web API back-end for an app. The app is currently planned only for WP8, but we also plan to roll out versions for other platforms at a later time.

We are basing our push notifications on the Azure Notification Hub. The app will not register directly, but will call a Web API method, which will do the registration for the app.

There are two things I am having trouble wrapping my head around:

  1. I can't find any documentation on sending notifications to individual WP8 users. I don't want to broadcast; I just want to send one notification to one user. Is this use-case supported? How can this be done using the Microsoft.ServiceBus.Notifications API?

  2. I found this: http://www.windowsazure.com/en-us/documentation/articles/notification-hubs-aspnet-notify-users/ - This implements a lot of the functionality I need, in terms of notifications. The sample includes only iOS and Windows store apps. Is this because this use case is not supported on WP8? I can't see why, but I'm kind of new to WP8.

like image 517
Elad Lachmi Avatar asked Feb 06 '14 10:02

Elad Lachmi


People also ask

Can a function app bind to a notification hub?

Azure Functions supports output bindings for Notification Hubs. Azure Notification Hubs must be configured for the Platform Notifications Service (PNS) you want to use.

How does Azure notification hub work?

Azure Notification Hubs is a massively scalable mobile push notification engine for quickly sending millions of notifications to iOS, Android, Windows, or Kindle devices, working with APNs (Apple Push Notification service), GCM (Google Cloud Messaging), WNS (Windows Push Notification Service), and more.

Is Azure notification hub free?

Notification Hubs is offered in three tiers—free, basic and standard. Base charge and quotas are applied at the namespace level. Pushes exceeding included amounts are aggregated at the subscription level for each tier.


3 Answers

Azure notification hubs support tags, as in the example here.

In a Channel9 web-cast (which I can't find right now), they talked about leveraging tags in order to send notifications to specific users/groups.

Since I would like to leverage all the added value of the Notification Hubs, I will tag each entry with the username used in my application, and use that to send norifications to specific users by username.

EDIT: Here in the official Windows Azure documentation I found an example talking about exactly what I was looking to do. As an added bonus, they also gave me the idea to also tag with an installation ID, so you can have the same user getting native notifications on different devices with different operating systems.

like image 145
Elad Lachmi Avatar answered Nov 07 '22 15:11

Elad Lachmi


Notification hub - for broadcasting notifications to a large mobile audience.

Push via mobile services - for specific notifications. Refer Q4 in the Q & A section here http://blogs.msdn.com/b/windowsazure/archive/2013/10/11/recap-mobile-services-azurechat.aspx

Push notification in mobile services

like image 23
Aravind Avatar answered Nov 07 '22 16:11

Aravind


While others here have already covered using tags, there is another option that is not as well known. The Azure Notification Hubs REST API documentation on MSDN has the following Direct Send page: https://msdn.microsoft.com/en-us/library/azure/mt608572.aspx

Essentially, you add "direct" to the query string in the URL and provide the push token as a "*-DeviceHandle" header.

Users of this API do not need to use Registrations or Installations. Instead, users of this API manage all devices on their own and use Azure Notification Hub solely as a pass through service to communicate with the various Push Notification Services.

What does this mean? You need to get the device push token from the client before calling the ANH REST API (and re-use it efficiently).

One last note, for anyone who came across this previous but shied away from it: the documentation used to state that you had to contact support to opt into the feature, but it was recently updated to remove this caveat when I asked about it. :)

like image 36
Matt Kerr Avatar answered Nov 07 '22 15:11

Matt Kerr