title: Azure Notification Hub: How to handle registration for a million devices?
body: <p><strong>Requirement-</strong></p>
  
  <p>The requirement is to send notifications to devices on specific times. That is, if a user has setup a schedule at 07:00 AM for breakfast, he'll get a notification for the same like 'Its time for breakfast, blah blah blah!'.</p>
  
  <p><em>However,</em> if the user has already had his breakfast before 07:00 AM, he'll make his diary entry on what he had etc. and then the notification must not be sent to him.</p>
  
  <p>This is a recurring schedule and the user will only change this if he needs to, otherwise, the schedule will mostly be the same.</p>
  
  <p><strong>What we have achieved?-</strong></p>
  
  <p>So, for now what we do is to register devices with tags like '{TimeZone:EST},{Breakfast:07:00:00}' on the app's launch.</p>
  
  <p>In case, the user has already had his breakfast, we update his registration on notification hub to also contain a tag like '{HadBreakfast}' - So, the set of tags user's device is registered to becomes - '{TimeZone:EST},{Breakfast:07:00:00},{HadBreakfast}'</p>
  
  <p><strong>What are we stuck at?-</strong></p>
  
  <p>This approach will work very well because, when sending notifications, we use tag expression like - '{TimeZone:EST} &amp;&amp; {Breakfast:07:00:00} &amp;&amp; !{HadBreakfast}'</p>
  
  <p>So, this will send a notification to all users that wants a notification for breakfast at 07:00:00 AM for EST timezone but not to the ones who already had their breakfast.</p>
  
  <p><em>However,</em> if the user is registered with a tag like {HadBreakfast}, then the next day, he might not get the notification based on the logic just described.</p>
  
  <p>So, we came up with the workaround to de-register only the {HadBreakfast} tag at the end of day for all the devices which has that tag by running a scheduler.</p>
  
  <p>But, somewhere in our mind, we think that is not the best solution for this problem.</p>
  
  <p><strong>Other Alternative-</strong></p>
  
  <p>We also thought of another alternative that we can run a scheduler for every hour within which, it will do the same thing of removing such tags for the past hour for all the user devices which has that tag - and this process seems to be effective than running it once in a day.</p>
  
  <p><em>But we wanted to know thoughts from the community on what I can try out? If the method that we use is correct or not? What else could be done to do this more simply OR smoothly? <strong>What if we have a million plus devices? Will this work?</em></strong></p>