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

117 views Asked by At

I know how to send targeted messages from the various tutorials with code like that:

// 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);

But I struggle to figure out how to send to all my registered UserIds.

I hope there is some method like:

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

There are 1 answers

1
Nikita R. On BEST ANSWER

Yes, there's an overload of SendTemplateNotificationAsync that looks exactly as you described:

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

Does it not work for you?

An alternative would be to register your users with an additional tag (e.g. "registered user" for all users or "paid user"/"trial user" if you need to slice them somehow) and then use the method you're currently using to send messages, but to this broader tag.