title: Swift 3 - How to make timer work in background
body: <p>i am trying to do an application which can make a timer run in background.</p>
  
  <p>here's my code:</p>
  
  <pre><code>let taskManager = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(self.scheduleNotification), userInfo: nil, repeats: true)
          RunLoop.main.add(taskManager, forMode: RunLoopMode.commonModes)
  </code></pre>
  
  <p>above code will perform a function that will invoke a local notification.
  this works when the app is in foreground, how can i make it work in the background?</p>
  
  <p>i tried to put several print lines and i saw that when i minimize (pressed the home button) the app, the timer stops, when i go back to the app, it resumes.</p>
  
  <p>i wanted the timer to still run in the background. is there a way to do it?</p>
  
  <p>here's what i want to happen:</p>
  
  <p>run app -> wait 10 secs -> notification received -> wait 10 secs -> notification received -> and back to wait and received again</p>
  
  <p>that happens when in foreground. but not in background. pls help.</p>