社交网络方案中的 Azure 通知中心最佳实践 [英] Azure notification hub best practice in social network scenario

查看:64
本文介绍了社交网络方案中的 Azure 通知中心最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am wondering which is the best practice in Azure notification hub to send push notifications to a couple of certain users (e.g. about followed activities).

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

Imagine, users can follow other users and these followers should be notified about new activities (facebook, twitter principle).

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

How to send these notifications in detail, there are two options I am thinking about, but which one is the best?

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

1) looping through all desired users by code and calling SendTemplateNotificationAsync for each individual user?

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

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

2) Having special tags a user can register to

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.

It's possible that a user follows up to 1.000 other users, so he needs to register 1.000 of the followerUserId-Tag.

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

Is the second approach a reliable solution?

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

Are there any tag limitations a user can register to?

推荐答案

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

This answer describes tag limits on NH. There is a limit of 60 tags per registration, so you won't be able to use your second approach if you want to allow 1k followers.

您可以使用 SendNotificationAsync(Notification, IEnumerable) 重载方法 将第一个场景中的第 20 组调用最多保存到第 20 组您拨打该服务的电话.

You can use the SendNotificationAsync(Notification, IEnumerable<String>) overload of the method to "batch" calls in your first scenario in groups of 20 max to save on the number of calls you make to the service.

这篇关于社交网络方案中的 Azure 通知中心最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆