【问题标题】:Azure notification hub best practice in social network scenario社交网络场景中的 Azure 通知中心最佳实践
【发布时间】:2017-06-08 08:55:18
【问题描述】:

我想知道在 Azure 通知中心向几个特定用户发送推送通知(例如关于关注的活动)的最佳做法是什么。

想象一下,用户可以关注其他用户,并且应该通知这些关注者有新的活动(facebook、twitter 原则)。

如何详细发送这些通知,我正在考虑两种选择,但哪一种最好?

1) 通过代码循环遍历所有需要的用户并为每个单独的用户调用SendTemplateNotificationAsync

foreach(user in allSubscribedUsers) {
    tags.Add("userid:" + userId);
    await hub.SendTemplateNotificationAsync(notification, tags);
}

2) 具有用户可以注册的特殊标签

registration.Tags = new HashSet<string>(deviceUpdate.Tags);

// the current user follows other users with the ids 1,2 and 3
registration.Tags.Add("followerUserid:1");
registration.Tags.Add("followerUserid:2");
registration.Tags.Add("followerUserid:3");
...
// an acivity by user with id 2 is happen
// send a push notification to all users who follow the user with id 2
tags.Add("followerUserid:2");
await hub.SendTemplateNotificationAsync(notification, tags);

一个用户可能最多关注 1.000 个其他用户,因此他需要注册 1.000 个 followerUserId-Tag

第二种方法是否可靠?

用户可以注册是否有任何标签限制?

【问题讨论】:

    标签: c# azure push-notification azure-notificationhub


    【解决方案1】:

    This answer 描述了 NH 的标签限制。每次注册有 60 个标签的限制,因此如果您想允许 1k 关注者,您将无法使用第二种方法。

    您可以使用 SendNotificationAsync(Notification, IEnumerable&lt;String&gt;) overload of the method 在您的第一个场景中以最多 20 个为一组“批量”调用,以节省您对服务的调用次数。

    【讨论】:

    • 感谢您的回答!但是链接线程中的下一篇文章说,MS 已经消除了标签限制?
    • 这有点令人困惑,但标签限制有很多方面。 每台设备的标签数为 60。但标签总数的上限为 3000。不过,带有
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-07
    • 1970-01-01
    • 1970-01-01
    • 2019-02-18
    • 2014-09-14
    • 2017-10-20
    • 1970-01-01
    相关资源
    最近更新 更多