C# 使用Azure通知中心安装模型时如何获取所有安装?

C# 使用Azure通知中心安装模型时如何获取所有安装?,c#,.net,azure,push-notification,azure-notificationhub,C#,.net,Azure,Push Notification,Azure Notificationhub,使用NotificationHubClient我可以使用getAllRegistrationAsync()获取所有信息。但是,如果我不使用注册模型,而是使用安装模型,那么如何获得所有安装?有几种方法可以检索一个集线器,但没有一种方法可以获取所有信息。您是正确的,截至2016年7月,无法获取集线器的所有安装信息。将来,产品团队计划将此功能添加到安装模型中,但它将以不同的方式工作。您将提供存储连接字符串,而不是将其作为运行时操作,并将得到一个包含与中心相关的所有内容的blob 很抱歉访问了一个旧线程

使用
NotificationHubClient
我可以使用
getAllRegistrationAsync()
获取所有信息。但是,如果我不使用注册模型,而是使用安装模型,那么如何获得所有安装?有几种方法可以检索一个集线器,但没有一种方法可以获取所有信息。

您是正确的,截至2016年7月,无法获取集线器的所有安装信息。将来,产品团队计划将此功能添加到安装模型中,但它将以不同的方式工作。您将提供存储连接字符串,而不是将其作为运行时操作,并将得到一个包含与中心相关的所有内容的blob

很抱歉访问了一个旧线程。。。但理论上,您可以使用GetAllRegistrationAsyc获取所有安装。我猜这也会返回没有安装id的所有内容,但是如果您选择,您可以忽略这些内容

可能看起来像这样

        var allRegistrations = await _hub.GetAllRegistrationsAsync(0);
        var continuationToken = allRegistrations.ContinuationToken;
        var registrationDescriptionsList = new List<RegistrationDescription>(allRegistrations);
        while (!string.IsNullOrWhiteSpace(continuationToken))
        {
            var otherRegistrations = await _hub.GetAllRegistrationsAsync(continuationToken, 0);
            registrationDescriptionsList.AddRange(otherRegistrations);
            continuationToken = otherRegistrations.ContinuationToken;
        }

        // Put into DeviceInstallation object
        var deviceInstallationList = new List<DeviceInstallation>();

        foreach (var registration in registrationDescriptionsList)
        {
            var deviceInstallation = new DeviceInstallation();

            var tags = registration.Tags;
            foreach(var tag in tags)
            {
                if (tag.Contains("InstallationId:"))
                {
                    deviceInstallation.InstallationId = new Guid(tag.Substring(tag.IndexOf(":")+1));
                }
            }
            deviceInstallation.PushHandle = registration.PnsHandle;
            deviceInstallation.Tags = new List<string>(registration.Tags);

            deviceInstallationList.Add(deviceInstallation);
        }
var allRegistrations=wait\u hub.GetAllRegistrationsAsync(0);
var continuationToken=allRegistrations.continuationToken;
var注册描述列表=新列表(所有注册);
而(!string.IsNullOrWhiteSpace(continuationToken))
{
var otherRegistrations=wait_hub.getAllRegistrationAsync(continuationToken,0);
RegistrationDescriptionList.AddRange(其他注册);
continuationToken=其他注册。continuationToken;
}
//放入设备安装对象
var deviceInstallationList=新列表();
foreach(注册描述列表中的var注册)
{
var deviceInstallation=新设备安装();
var tags=registration.tags;
foreach(标签中的var标签)
{
if(tag.Contains(“InstallationId:”))
{
deviceInstallation.InstallationId=新Guid(tag.Substring(tag.IndexOf(“:”)+1));
}
}
deviceInstallation.PushHandle=registration.PnsHandle;
deviceInstallation.Tags=新列表(registration.Tags);
添加(deviceInstallation);
}

我并不是说这是编写的最干净的代码块,但它确实为我们带来了好处。无论如何,我们只将其用于调试类型的目的

是否…这还会出现?@gorillapower,根据产品团队的说法,它仍在待办事项中。但是,不幸的是,它何时可用还没有预计到达时间。那么如何更新所有安装的模板呢?是否有一个github许可证,我们可以对此进行投票并施加压力,以便更快地解决问题?@DeanPuckett,不幸的是,我不这么认为。我不知道NH团队使用GH(或其他面向公众的方式)来制定计划和跟踪进度。