title: Background tasks iPhone
body: <p>I am trying to implement location updates in the background based on a timer. I know all about the different location updating methods in iOS and have tried them but they don't fit the need. I need to check locations every so often even while not active. I've tried using timers but they don't execute in the background. That led me to find this question <a href="https://stackoverflow.com/questions/6347503/how-do-i-get-a-background-location-update-every-n-minutes-in-my-ios-application">How do I get a background location update every n minutes in my iOS application?</a> and it mentions using </p>
  
  <pre><code>UIApplication:beginBackgroundTaskWithExpirationHandler:
  </code></pre>
  
  <p>My questions is how do you use this method? I've searched the apple docs but they are recursively pointing at each other when dealing with background execution and location updates with no examples.</p>
  
  <p>I have this code now based on some examples I've found:</p>
  
  <pre><code>- (void)applicationDidEnterBackground:(UIApplication *)application
  {    
      locationUpdater=[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
          [[UIApplication sharedApplication] endBackgroundTask:locationUpdater];
          locationUpdater=UIBackgroundTaskInvalid;
      } ];
  }
  </code></pre>
  
  <p>And I have added the key "location" in the .plist for supported background modes</p>
  
  <p>Does adding this just guarantee that my application won't be killed for some certain amount of time so I can keep a timer running? or where do I add the methods that are to get executed while in the background mode.</p>