title: Background fetch What time runs out?
body: <p>I want to know what the actual device will occur when the backgroundfetch mode</p>
  
  <p>For example, the following code:</p>
  
  <p>Step 1: Enable capabilities "background fetch"</p>
  
  <p>Step2 : Setup AppDelegate.swift </p>
  
  <pre><code>func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
  
      let settings = UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert, categories: nil)
  
      UIApplication.sharedApplication().registerUserNotificationSettings(settings)
  
      UIApplication.sharedApplication().setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
  
      return true;
  
  
  
  
  
  }
  </code></pre>
  
  <p>Step 3: Register application event in AppDelegate.swift, to register completion handler</p>
  
  <pre><code>func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -&gt; Void) {
  
      println("Complete");
  
      completionHandler(UIBackgroundFetchResult.NewData)
  
  
  
      getData();
  
  
  
  }
  
  
  
  func getData() -&gt; Void{
  
      var url = "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?apikey=xxxxxx&amp;limit=20";
  
      var request = NSURLRequest(URL: NSURL(string: url));
  
  
  
      NSURLConnection.sendAsynchronousRequest(request,queue: NSOperationQueue.mainQueue()) {
  
          (response: NSURLResponse!, data: NSData!, error: NSError!) -&gt; Void in
  
          var moviesResult = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) as NSDictionary;
  
          var movies: [NSDictionary]=[];
  
          movies = moviesResult["movies"] as [NSDictionary];
  
          var localNotification:UILocalNotification = UILocalNotification()
  
          localNotification.alertAction = "Testing notifications on iOS8"
  
          localNotification.alertBody = "Movie Count : \(movies.count)"
  
          localNotification.fireDate = NSDate(timeIntervalSinceNow: 1)
  
          UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
  
      }
  
  
  
  
  
  }
  </code></pre>
  
  <p>When the getdata function executed ?</p>
  
  <p>Have time the program is fully closed,</p>
  
  <p>Always running?</p>