Sending tags containing special characters to Azure Notification Hub

2.4k Views Asked by At

We want to use Azure Notification Hubs in our iPad app but we have run into a problem. The tags that determine who gets the push message is an email address and it works fine if it only contains normal characters. But it does not work when we try to send a tag looking like this:

[email protected]

or

test%[email protected]

We are using this method to send push from the backend:

http://msdn.microsoft.com/en-us/library/windowsazure/dn539552.aspx

When we do so we get this message:

Invalid tag [email protected]:48b6f399-3f27-40b4-a6f9-b0838623c9c3_G19,TimeStamp:12/10/2013 12:38:38 PM

Invalid Request (400)

We have looked through the documentation to see if it states somewhere that we need to encode tags in a special way but have found nothing.

We cannot imagine that this is not possible since it must be a common scenario. Hope someone can help.

Cheers

2

There are 2 best solutions below

1
On

The allowed characters in tags are: ASCII-7 alphanumeric characters plus {‘.’, ’-’, ’_’, ’~’, ‘:’, ‘@’, ‘#’}. Max length is 120 chars.

You can encode arbitrary strings by encoding it in binary and then hex.

Info Source

0
On

I found slightly different information to Elio:

A tag can be any string, up to 120 characters, containing alphanumeric and the following non-alphanumeric characters: ‘_’, ‘@’, ‘#’, ‘.’, ‘:’, ‘-’.

Source

So '~' is invalid (I can confirm this from experience).