Open eric-labelle opened 3 years ago
@eric-labelle I'll update the documentation for the SDK to be more in line with the Apple SDK which has this information.
To target a user, use the tag $UserId:{VALUE}
where VALUE
is the user ID you are targeting. This is also true of InstallationId which can be targeted using $InstallationId:{VALUE}
.
To target the push channel directly, use the Direct Send capability of Azure Notification Hubs with the given device token.
oh wow, ok! never would have guess this one for userId. Thanks
For the Direct Send, that's not in the Azure Portal, only through REST API? There is only a "Test Send" button in the Azure portal.
@eric-labelle correct, Direct Send is through the REST API directly. The portal is just using the normal targeted send. You can, however, if you know the Installation ID, target it that way through the portal
@mpodwysocki I just tested both. Works well. Im curious though what is the RegistrationId
column in the "Test Send" result table from the Azure Portal? Can't seem to get this value from ANH sdk (only have the pushChannel which seems to be the FCM token, and the InstallationId). Just don't get why sometime it send message to multiple registrationId when It should have targetted only one device.
@mpodwysocki are you able to send to a group of users using $UserId:{VALUE}
method? If so, any idea how? or where we can lookup expression building examples in their docs?
I my payload looks like this:
var notification = "{\"aps\":{\"alert\":\"Test alert!\"}}";
where does $UserId:{VALUE}
go? And I assume we have to MSNotificationHub.setUserId(userId);
on the iOS side, correct?
@frankfuu Yes, you can set the same userId when registering those devices, and if you send a notification with the tag "$UserId:{VALUE}", the notification will be sent to all those devices.
Note that conceptually, UserID is meant to be used as an identifier for all the devices that belong to a single user. So a better way to send a notification to a group of users would be to add a unique group tag when registering the devices that belong to a group. And then, when sending a notification, you can specify the group tag that you want to target for that notification.
More info on using Tags with ANH: https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-tags-segment-push-message
@ljunquera You will need to provide $UserId:{VALUE}
as the Tag when sending the notification.
More info on using Tags with ANH: https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-tags-segment-push-message
Query/Question Using the method
NotificationHub.setUserId()
from the Android sdk, how can we send a notification from the Azure Console to that user? There's only a "Send to Tag Expression" field but using the userId there won't work obviously. Just curious what this setUserId is used for if there is no way to send a push notification to only this user.On an additional note, it would also be useful to be able to send a notif directly to the pushChannel (which is kind of the pushToken from what I understand in ANH) Also, is there a way to see registered devices/users/tags in the console? can't find this anywhere.
Setup (please complete the following information if applicable):
Version of the Library used: 1.1.1
Information Checklist