Windows Azure ServiceBus Push Notifications APNS Architecture

匆匆过客 提交于 2019-12-10 19:50:13

问题


I am building an application hosted on windows azure which will send messages to users on iphones through the apns. I am using a service bus notification hub rather than a mobile service as I have an existing persistence infrastructure using RavenDB and queues.

Say this is my notification service's send to apple method:

public async void SendAppleNotificationAsync(INotification notification)
        {            
            var hub = NotificationHubClient.CreateClientFromConnectionString(
                _configService.Get<NotificationConfig>().ConnectionString, 
                _configService.Get<NotificationConfig>().Hub);

            var appleNotification = new AppleNotification(notification.ToJsonString(), new DateTime());

            await hub.SendNotificationAsync(appleNotification);
        }

What I am unable to work out is how to send a notification to a specific device, given I have the user's device token from apple stored in my server side application.

I was hoping the api had a method like this:

var appleNotification = new AppleNotification(deviceToken, notification.ToJsonString(), new DateTime());

But I don't seem to be able to find any reference to targeting a specific device.

Am I missing something fundamental to the picture?


回答1:


Notification Hubs can be used to send out bulk notifications to groups of users, or to single users. It is basically a publish/subscribe model. The client subscribes to a topic and the server publishes notifications to that topic. A client might subscribe to a broad topic "promotions" or a narrow topic "user:123456". This article gives example code and a walkthrough of using Notification Hubs to send a message to a single client.

http://www.windowsazure.com/en-us/documentation/articles/notification-hubs-aspnet-notify-users/



来源:https://stackoverflow.com/questions/21323712/windows-azure-servicebus-push-notifications-apns-architecture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!