Closed tylerablake closed 5 years ago
Hey @tylerablake , I'm using tags in 2 production apps and I never had any problems. How are you sending your notifications? Are you using the send push in the azure portal/visual studio? If not, I suggest you try it from there first.
Yes I am trying from the Azure Notification Hub test send.
This is what I am doing in code
client.push.registerWithTags(token, ["username:test"])
.then(() => {
console.log("Azure Register OK!", client.push.installationId);
})
.catch((e) => {
console.dir(e);
});
In the Azure notification hub I'm just setting the tag textbox to "username:test".
Have you whitelisted your tags in azure? from the push blade:
Tags To send targeted notifications, assign tags to devices to segment your audiences. Client Requested tags are whitelisted tags that clients can directly register for without going through the backend. Automatically Added tags automatically assign tags to devices based on user claims from authentication.Learn More
Ahh! Thank you, I didn't see that.. Thank you again for your help!
@PeterStaev Is there anyway to not have to manually whitelist the tags inside of the Azure Notification Hub?
I dynamically create the tags inside of my app so every time an anonymous user creates an object, I'm using that objects Guid as the tag to send notifications to that person.
Everything I've read says that I just register with the new tag and when that happens the Notification Hub should add that tag to its list. See the comment from Stack Overflow here: https://stackoverflow.com/questions/36644788/how-to-create-notification-hub-tags-programmatically
Thank you for your continued help with this!
@tylerablake , yes there is a way, but you have to do this on you backend. For example in the projects I have added this I have service call in my backend that uses the FullSharedAccessSignature that give you ability to manage the tags w/o the need to whitelist them. Here is part of my code:
Dim oHubClient = NotificationHubClient.CreateClientFromConnectionString(ConfigurationManager.AppSettings("NotificationHub.ConnectionString"),
ConfigurationManager.AppSettings("NotificationHub.Name")
)
Dim oTags As New JArray()
oTags.Add("office:" + GetCurrentOffice())
oTags.Add("userId:" + GetCurrentUserId())
Dim arrUpdateOps = New List(Of PartialUpdateOperation)()
arrUpdateOps.Add(New PartialUpdateOperation With
{
.Operation = UpdateOperationType.Replace,
.Path = "/tags",
.Value = oTags.ToString(Newtonsoft.Json.Formatting.None)
})
oHubClient.PatchInstallation(oRequest.installationId, arrUpdateOps)
So on the device I'm just registering the device with Azure, I'm getting the installationId
and send it to the backend, which executes the code above. This adds the tags to that installationId
.
On a side note - since in all my apps I'm just using notification hubs, I'm in the process of creating a new lightweight plugin just for NotificationHubs. And from what I see there is no such restriction there - i.e. I can freely assign tags and they work as expected out of the box 😄
Ok thanks I'll give that a try! That plugin sounds great! This is my first project using NotificationHubs so I'm still learning.
Hi,
I didn't see any issues regarding tags for push notifications in this repository but wanted to check with you.
I am trying to register with NotificationHub using tags. I get an OK response back from the Azure client but when I try to send the notification out with the tags I set, I am not receiving the notification.
Let me know if you need any additional information from me.
Thanks,
Tyler