title: How to use background task using Swift 3?
body: <p>I am new in background tasks. I have a small work that I am fetching tweets and If my app is in background mode then also it should fetch tweets, but I don't know how.</p>
  
  <p>I am using simply Timer in Appdelegate didFinishLaunchOption Method. When I will close the app then it's not working. I am new in that so please any suggestion. Here below is my code:</p>
  
  <pre><code>Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(getTweets), userInfo: nil, repeats: true). 
  
  func getTweets() {
  
      let locationName = Helper.sharedInstance.userDefault.value(forKey: ModelKey.currentLocation) as? String
  
      let accessToken = Helper.sharedInstance.userDefault.value(forKey: ModelKey.twitterAccessToken) as? String
  
      if (locationName == "Bengaluru" &amp;&amp; nil != accessToken) || (locationName == "Bangalore" &amp;&amp; nil != accessToken){
          tweetModel.getTweets(accessToken: accessToken!, city: ModelKey.blrcitytraffic, cityName: "Bengaluru")
      }
  }
  </code></pre>
  
  <p>Text to speech is also there but when I will close the app then it stops speaking. If I am not using app then also it can fetch tweets and text to speech should work using a background mode. How long does that work?</p>