title: iOS 10 UNUserNotificationCenterDelegate not called. push notifications not working
body: <p>Tearing my hair out tying to get push notifications to work in iOS10. Current setup:</p>
  
  <p>in <code>func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -&gt; Bool</code>:</p>
  
  <pre><code>if #available(iOS 10.0, *) {
  
              let center = UNUserNotificationCenter.current()
              center.delegate = self
              center.requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in
  
                  if error == nil {
                      print("DID REQUEST THE NOTIFICATION")
                      UIApplication.shared.registerForRemoteNotifications()
                  }
              }
              print("DID SET DELEGATE")
          }
  </code></pre>
  
  <p>In <code>func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)</code>:</p>
  
  <pre><code>print("DID REGISTER FOR A REMOTE NOTIFICATION AND THE TOKEN IS \(deviceToken.base64EncodedString())"           
  let request = UpdatePushNotificationSubscription_Request(deviceToken: deviceToken)
  updatePushNotificationSubscriptionWorker.updateSubscription(request)
  </code></pre>
  
  <p>I have checked the token is uploaded to the backend correctly and it does indeed match.</p>
  
  <p>I have also implemented:</p>
  
  <pre><code>    @available(iOS 10.0, *)
      func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -&gt; Void) {
  
          print("GOT A NOTIFICATION")
  
      }
  
  
      @available(iOS 10.0, *)
      func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -&gt; Void) {
  
          //This is for the user tapping on the notification
          print("GOT A NOTIFICATION")
      }
  </code></pre>
  
  <p>I have set the entitlements for all targets and enabled push:</p>
  
  <p><a href="https://i.stack.imgur.com/slJXQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/slJXQ.png" alt="enter image description here"></a></p>
  
  <p>Now when I try to send a message from the backend the device just receives nothing. Delegates are not being called. Have no idea what I'm doing wrong here. Push is working for iOS9 and android devices. Any pointers to what I might be doing wrong?</p>