Partition new device registrations into multiple Azure Notification Hub namespaces?

Panagiotis Tzedakis 22 Reputation points
2022-04-06T19:22:19.637+00:00

Hello,

I am going to setup two Azure NH Namespaces in Basic Tier, so that I can cover the push notification needs of my user base of 250K users.

From reading the docs, I understand that if I use the server-side (backend) method to register new device installations to my Azure NH and I reach the maximum number of device registrations in the 1st namespace, the next device registration to get created would result in an error.

So, if I have logic in place to check against this issue and create the next device registration to the 2nd namespace, does this not mean that I need to return to the client app the connection details and hubname of the 2nd namespace, so that the client app will know which Azure NH namespace connection/hubname to connect in order to "listen" to new push notifications?

In the same logic, every time my backend gets called to Create/Update a device installation, it should check if it exists in either the 1st or 2nd namespace and if it does NOT exist in any of them, then attempt to create it in the 1st namespace and if that fails, attempt to create it to the 2nd namespace. Is my logic correct or I am missing something?

Finally, when my backend needs to send a broadcast push notification to ALL device registrations (installations) stored to the 1st and 2nd namespaces, do I need to have a loop in place to send every push notification to the 1st namespace/hub, then the 2nd namespace/hub?

Thanks for any help/pointers.
BR,
P.

Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
327 questions
{count} votes

1 answer

Sort by: Most helpful
  1. sadomovalex 3,631 Reputation points
    2022-04-19T15:08:35.22+00:00

    yes in general direction is correct. For sending push notifications you will need connection string to NH. Each NH has own connection string regardless of are they located in the same NH namespace or in different namespaces. In order to send push notifications to all devices you have to enumerate all these connection strings.

    When device is registered in particular NH - this device will get push notification which is sent with connection string of this NH. For more advanced scenarios (like sending push notification to particular user or device) several things are needed:

    • push notifications should be created with tags (which will allow to use tag rules to send push notification to particular user/device). Eg. userId = '...'
    • you need to know in which particular NH this user/device is registered. For that you may use database table and store infromation about existing registrations there and their relation with particular NH

    With this approach you may use more than 2 namespaces and multiple notification hubs per single namespace.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.