title: Custom local notification in background swift 4
body: <p>I have written some code to implement custom notification in my app but that does not seems to work when app is in background mode here is code below:</p>
  
  <pre><code>let content = UNMutableNotificationContent()
          content.title = "test notifaction"
          content.body = "test notification after 5 second"
          content.sound = UNNotificationSound.default()
  
          let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: true)
          let request  = UNNotificationRequest(identifier: "testidentifire", content: content, trigger: trigger)
  </code></pre>
  
  <p>In app delegate</p>
  
  <pre><code>//user notification method
      func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -&gt; Void) {
          completionHandler([.alert,.sound])
      }
      //response to user notification
      func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -&gt; Void) {
          if response.notification.request.identifier == "testidentifire"
          {
              print("test")
          }
          completionHandler()
      }
  
  
  
  
      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -&gt; Bool {
  
          UNUserNotificationCenter.current().delegate = self
  
          UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.sound,.badge]) { (granted, error) in
              print("granted\(granted)")
          }
          return true
      }
  </code></pre>
  
  <p>now when I search I found the same code every where I can not understand whats wrong with my code</p>