Azure 移动应用程序:如何向 Android + iOS 广播跨平台消息

Azure Mobile Apps: How to broadcast a cross platform message to Droid + iOS

我知道如何使用这样的代码从各种教程中发送有针对性的消息:

// Get the current user SID and create a tag for the current user.
var claimsPrincipal = this.User as ClaimsPrincipal;
string sid = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier).Value;
string userTag = "_UserId:" + sid;

// Build a dictionary for the template with the item message text.
var notification = new Dictionary { { "message", item.Text } };

// Send a template notification to the user ID.
await hub.SendTemplateNotificationAsync(notification, userTag);

但我很难弄清楚如何发送到我所有注册的 UserIds。

我希望有这样的方法:

// Send a template notification to all UserIds
await hub.SendTemplateNotificationAsync(notification);

是的,overload of SendTemplateNotificationAsync 与您描述的完全一样:

public Task<NotificationOutcome> SendTemplateNotificationAsync(
                                       IDictionary<string, string> properties)

它不适合你吗?

另一种方法是为您的用户注册一个额外的标签(例如 "registered user" 用于所有用户,或者 "paid user"/"trial user" 如果您需要以某种方式对它们进行切片)然后使用您当前用于发送消息的方法,但发送到这个更广泛的标签。