Azure通知中心社交网络方案中的最佳实践

我想知道哪个是Azure通知中心的最佳实践,可以向几个特定用户发送推送通知(例如关于后续活动)。

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

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

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

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

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

 registration.Tags = new HashSet(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

第二种方法是可靠的解决方案吗?

用户可以注册的标签限制是什么?

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

您可以使用方法的SendNotificationAsync(Notification, IEnumerable) 重载在第一个方案中以20个最大组的方式 “批处理”呼叫,以节省您对服务的呼叫数量。