title: didReceiveRemoteNotification not called - why?
body: <p>I'm having a problem with my app and the UserNotifications framework. I've got a main view controller with a sendNotification()-function as the following:</p>
  
  <pre><code>let content = UNMutableNotificationContent()
          content.title = "Water Reminder"
          content.body = "What about a glass of water?"
          content.sound = UNNotificationSound.default()
  
          let testTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 30, repeats: false)
  
          let identifier = Int(arc4random_uniform(999999999))
  
          let request = UNNotificationRequest(identifier: "\(identifier)", content: content, trigger: testTrigger)
  
          center.add(request, withCompletionHandler: {
              (error) in
              if let error = error {
                  print("Didn't add notification request. \(error)")
              }
  
          })
  </code></pre>
  
  <p>The trigger is just for testing. Well, after 30 seconds, I receive the notification. To that point, everything is fine. The problem is: when it has received a reminder, it should call the didReceiveRemoteNotification()-function in the app delegate, but it doesn't. Here's my function:</p>
  
  <pre><code>func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -&gt; Void) {
  
      UserDefaults.standard.set(true, forKey: "didReceiveRemoteNotification")
  }
  </code></pre>
  
  <p>So, I have received the notification, inserted in the didFinishLaunchingWithOptions()-function this line of code: </p>
  
  <pre><code>print("\(UserDefaults.standard.bool(forKey: "didReceiveRemoteNotification")")
  </code></pre>
  
  <p>and it gives me false, even though I HAVE received a notification. How is that possible?</p>
  
  <p>In the capabilities section, background modes for notifications and background fetch are activated as well as push notifications. App delegate and view controller have both imported UserNotifications, are added as UNUserNotificationCenterDelegate and both have got a center.delegate = self one of code. Why doesn't it work? Why does my didReceiveRemoteNotification()-function not get called?</p>
  
  <p>Thanks for your help...</p>