title: Setting application badge using provisional authorization in iOS 12
body: <p>So iOS 12 introduced Provisional Authorization for Quiet Notifications that could be seen in Notification Center but not on the Lock screen. It has very cool advantage - you don't need user's approval to send one. </p>
  
  <p>Several articles (<a href="https://www.smashingmagazine.com/2018/09/preparing-your-app-for-ios-12-notifications/" rel="noreferrer">smashingmagazine.com</a>, <a href="https://ios.gadgethacks.com/news/100-coolest-new-ios-12-features-you-didnt-know-about-0182804/" rel="noreferrer">gadgethacks.com</a>, etc.) claim that iOS app will be able to set it's badge if received Provisional Authorization. </p>
  
  <p>Is it really possible to set app badge when app is Provisionally Authorized? </p>
  
  <p>I request authorization using code below:</p>
  
  <pre><code>[[UNUserNotificationCenter currentNotificationCenter]
       requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionProvisional
       completionHandler:^(BOOL granted, NSError *_Nullable error) {
         if (granted) {
           [[UIApplication sharedApplication] registerForRemoteNotifications];
         }
       }];
  </code></pre>
  
  <p>I receive token at <code>didRegisterForRemoteNotificationsWithDeviceToken:</code> that could be used to send Push Notification. When I send Push Notification with a payload <code>{"aps":{"alert":"Testing..","badge":1}}</code> I see it in Notification Center but app doesn't get badged.</p>
  
  <p>I tried setting badge using <code>UIApplication.sharedApplication.applicationIconBadgeNumber = 1;</code> but it didn't work as well. It works though if I request regular authorization without providing UNAuthorizationOptionProvisional option.</p>