Sending tags containing special characters to Azure Notification Hub

淺唱寂寞╮ 提交于 2019-12-10 22:32:53

问题


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:

test+10@gmail.com

or

test%10@gmail.com

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 test+10@gmail.com.TrackingId: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


回答1:


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




回答2:


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).



来源:https://stackoverflow.com/questions/20494906/sending-tags-containing-special-characters-to-azure-notification-hub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!