当前位置: 动力学知识库 > 问答 > 编程问答 >

windows phone 8 - 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.

网友答案:

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.

网友答案:

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

网友答案:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: