Why are Azure Notification Hub tags not saving?

[亡魂溺海] 提交于 2019-12-31 05:40:27

问题


I am trying to send a message to notification hub, but my tags are not saving.

I checked service hub with service hub explorer, and tags are empty:

Registration of device:

var hs = new HashSet<string>();
        hs.Add(tag);
        hs.Add(sys.ToString());
        switch (sys)
        {
            case SystemVendorEnum.Android:
                await Hub.CreateGcmNativeRegistrationAsync(pnsHandle, hs);
                break;
            case SystemVendorEnum.Ios:
                await Hub.CreateAppleNativeRegistrationAsync(pnsHandle, hs);
                break;
        }

Test method invocation that sends message to hub:

// param1: json payload, param2: tag
await Hub.SendGcmNativeNotificationAsync("{ \"data\": { \"methodId\":\"1\" }}", "ae65d2d5-103e-4023-a784-c5c8e2684db0");

Is there anything I am missing? I don't have tags in notification hub:

Is that the case?


回答1:


I know, it's confusing, but there're two completely separate kinds of tags that have have no relationship to each other whatsoever:

  1. Tags that are within the context of Azure Notification Hub service. Those apply to device registrations. So, it's Notification Hubs service-specific and describes devices. See Routing and Tag Expressions for more details.
  2. Tags that as a concept of Azure Resource Manager (ARM). Those apply to any resource within Azure. So it's platform-specific and are used to describe any resource/service you have within Azure. See Using tags to organize your Azure resources for more details.

So when you call hs.Add(tag), the associated tags apply to the device registration (i.e. 'tags of the first kind') and should show up in the Service Bus explorer:

And if you go to Azure portal and navigate to any resource (or as you did, to your hub), you'll see ARM tags there (i.e. 'tags of the second kind'):



来源:https://stackoverflow.com/questions/36335644/why-are-azure-notification-hub-tags-not-saving

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