【发布时间】: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