Send notifications to individual users using Azure Notification Hub
Asked Answered
H

3

11

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.

Helban answered 6/2, 2014 at 10:26 Comment(5)
if you have not seen this already do check it out blogs.msdn.com/b/andy_wigley/archive/2013/08/22/…Yamada
@Yamada - Thanks. I have seen this, but it shows how to send a broadcast notification. I'm looking for an example of sending a single notification to a single user and this example is missing the part where the registration is identified by a device id and installation id.Helban
sometime back i worked on project that used MPNS to send push notifications to registered WP users.When u register MPNS provides a channelUri which is linked to the specific device/user. something like this #19150495Yamada
@Yamada - This example talks about manually storing and working with the Uris. I can do this, but I would like to leverage the Azure Notifications Hub.Helban
@Elad Look at [complete working implementation here][1]. You can directly use with minor changes [1]: #31913211Ruffian
H
12

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.

Helban answered 9/2, 2014 at 16:27 Comment(2)
Any reference to accomplish the same task on a javascript backend?Manassas
The URL to azure no longer works, try this instead: learn.microsoft.com/en-us/azure/notification-hubsInterrupt
Y
3

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

Yamada answered 7/2, 2014 at 7:21 Comment(2)
Nice! :) but I still have a problem with this. Notification Hubs seem more managed. I am all for the DIY approach, but not when I will have to manually manage millions of users (hoping for the best :)). The mobile hubs architecture sounds more robust and fully featured, and mobile services seem to be limited to 500 notifications per device per day.Helban
@EladLachmi I see your point. I have not explored mobile services much. May be you need to design it such a way to classify users who wanna be notified separately and part of bulk notifications. If individual notifications is the only option then you may think of using the uri approach.Yamada
H
3

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. :)

Heliometer answered 13/7, 2016 at 15:41 Comment(2)
Small update: you will need to use a Notification Hub of type Standard (which has different pricing)Heliometer
Update: It looks like this methodology may no longer be supported.Heliometer

© 2022 - 2024 — McMap. All rights reserved.