title: iOS: How to keep my application running in the background forever?
body: <p>my application is hosting a filesharing web server. And I want that the application is running, even when it in the background. I already know that I can run my application 3 minutes in the background by setting a <code>beginBackgroundTaskWithExpirationHandler</code> but this is not long enough. Is there a way to keep the app running forever, or at least for a much longer time?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I finally figured out a working way, its a bit odd but it works.</p>
  
  <p>I have on procedure</p>
  
  <pre><code>-(void)bgTask {
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"ApplicationURLScheme"]];
  }
  </code></pre>
  
  <p>that is been called in <code>applicationDidEnterBackground</code> with </p>
  
  <pre><code>[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
              [application beginBackgroundTaskWithExpirationHandler:^{
                  [self bgTask];
              }];
  </code></pre>
  
  <p>Thats it, no more code needed, I am running my Webserver in the Background for over an hour now! And the app is not lagging or crashing my iDevice!</p>