title: Call RESTful API while application in background state for indefinite time
body: <p>I want to call a post method every 60 seconds later while application is in background mode.My objective is to store user location and send it to my server.So far, for test purpose I have used <code>beginBackgroundTaskWithExpirationHandler</code> and <code>NSTime</code> for every 3 seconds call of a temporary post call and it's working fine. But problem is, this background task is being stopped after 10 times call. but I want it to call it indefinite times in certain interval(suppose every 60s or once in a day).</p>
  
  <p>Application iOS Deployment target : 9.0 and its Objective C project with swift compatibility. So far I have done this: </p>
  
  <pre><code>- (void)applicationWillResignActive:(UIApplication *)application {
  
      self.backgroundUpdateTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
      [self endBackgroundUpdateTask];
      }];
  }
  - (void) endBackgroundUpdateTask
  {
      [[UIApplication sharedApplication] endBackgroundTask: self.backgroundUpdateTask];
      self.backgroundUpdateTask = UIBackgroundTaskInvalid;
  }
  
  - (void)applicationWillEnterForeground:(UIApplication *)application {
      [self endBackgroundUpdateTask];
  }
  
  - (void)applicationDidEnterBackground:(UIApplication *)application {
  
      [NSTimer scheduledTimerWithTimeInterval:3.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
          [self targetMethod];
      }];
  }
  
  </code></pre>
  
  <p>can anyone help me out how can I call this <code>targetMethod</code> in regular interval?</p>
  
  <p>Thanks</p>