5

Using NotificationHubClient I can get all registered devices using GetAllRegistrationsAsync(). But if I do not use the registration model but the installation model instead, how can I get all installations? There are methods to retrieve a specific installation but none to get everything.

Nikita R.
  • 7,245
  • 3
  • 51
  • 62
Krumelur
  • 32,180
  • 27
  • 124
  • 263

2 Answers2

3

You're correct, as of July 2016 there's no way to get all installations for a hub. In the future, the product team is planning to add this feature to the installations model, but it will work in a different way. Instead of making it a runtime operation, you'll provide your storage connection string and you'll get a blob with everything associated with the hub.

Nikita R.
  • 7,245
  • 3
  • 51
  • 62
  • Is...this still coming? – gorillapower Feb 16 '18 at 15:02
  • @gorillapower, according to the product team, it's still in the backlog. But, unfortunately, there is no ETA on when it's going to be available. – Nikita R. Feb 20 '18 at 18:55
  • 1
    So how does one update a template for all installations? – Ian Warburton May 01 '18 at 17:59
  • Is there a github ticket open for this we can upvote and put pressure on for a quicker resolution? – Dean Puckett Jul 07 '20 at 09:09
  • @DeanPuckett, I don't think so, unfortunately. I am not aware of the NH team using GH (or other publicly-facing means) to lay out plans and track progress. – Nikita R. Jul 14 '20 at 20:54
  • I found the NotificationHub .NET team on Github and have raised an issue ticket with them. Please comment and contribute to get this sorted. https://github.com/Azure/azure-notificationhubs-dotnet/issues/143 – Dean Puckett Jul 23 '20 at 09:45
1

Sorry for visiting an old thread... but in theory you could use the GetAllRegistrationsAsyc to get all the installations. I guess this will return everything without an installation id as well, but you could just ignore those if you choose.

Could look something like this

        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);
        }

I am not suggesting this to be the cleanest chunk of code written, but it does the trick for us. We only use this for debugging type purposes anyways

AndySousa
  • 1,062
  • 2
  • 15
  • 30