title: How to increase notification badge number dynamically when local notification is delivered?
body: <p>My App sets up multiple notifications via a loop based on a calendar date and time.  While everything else is working correctly with this, I cannot seem to get the badge number to increment properly.  I have tried using a counter and setting</p>
  <pre><code>content.badge = self.counter as NSNumber
  ... or using ...
  content.badge = NSNumber(value: UIApplication.shared.applicationIconBadgeNumber + 1)
  </code></pre>
  <p>but what happens is something like the following:</p>
  <ol>
  <li>User gets notification 1,2,3,4,5 and badge number gets set to 5 content.badge = self.counter</li>
  <li>User then &quot;clears&quot; notifications 2 and 3 -&gt; and badge number is now 3 via my code (UIApplication.shared.applicationIconBadgeNumber - 1)</li>
  <li>When the next notification (number 6) pops up, the badge number SHOULD show 4. It doesn't. It shows 6 because that's what was set via content.badge</li>
  </ol>
  <p>What is the proper way to increment the badge number?  I've looked at various posts here but they're for push notifications.  Mine is for a local notifications.  Can I set/update badge number WHEN a notification is actually delivered?  I thought about trying this in...</p>
  <pre><code>func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -&gt; Void) {
      completionHandler([.alert, .badge, .sound])
      
  }
  </code></pre>
  <p>...but that seems to only be for in-app notifications.  Is there another function that I can do this in?</p>