【发布时间】:2017-08-02 05:39:57
【问题描述】:
如何设置我的推送通知,以便用户可以选择订阅哪个通知?以天气应用为例,用户 A 想在龙卷风临近时订阅通知,但用户 B 并不关心,只想在洪水临近时收到通知。因此,在应用程序中有一个设置允许用户订阅这些通知中的一个或两个。
现在在我的后端我有一个网络作业,它从在线资源收集天气数据并存储在 SQL 数据库中,我在 Azure 中创建了一个通知中心,并像这个示例一样将代码添加到我的网络作业
private static async void SendNotificationAsync()
{
NotificationHubClient hub = NotificationHubClient
.CreateClientFromConnectionString("<connection string with full access>", "<hub name>");
var toast = @"<toast><visual><binding template=""ToastText01""><text id=""1"">Hello from a .NET App!</text></binding></visual></toast>";
await hub.SendWindowsNativeNotificationAsync(toast);
}
当我获得某些表明洪水或龙卷风的天气数据时,我可以执行类似的操作来发送通知
if(flood)
SendNotificationAsync(flood) //only sends notification to User B
else if(tornado)
SendNotificationAsync(tornado) //only send notification to User A
这可以使用单个通知中心来完成吗?还是我必须创建多个集线器?
【问题讨论】:
标签: azure push-notification uwp azure-notificationhub