title: Send silent push notification to app, update location and send to server in background
body: <p>I want to send a silent push notification to an application that is in background, then fetch the current user location and send it to a web service.</p>
  
  <p>I implemented push notification methods and also those two:</p>
  
  <pre><code>- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  {
      NSDate *fetchStart = [NSDate date];
  
      [self sendLocationToServerWithCompletionHandler:^(UIBackgroundFetchResult result) {
          completionHandler(result);
  
          NSDate *fetchEnd = [NSDate date];
          NSTimeInterval timeElapsed = [fetchEnd timeIntervalSinceDate:fetchStart];
          NSLog(@"Background Fetch Duration: %f seconds", timeElapsed);
  
      }];
  }
  
  - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  {
  
  }
  </code></pre>
  
  <p>I've also created a method that will send the location to the server:</p>
  
  <pre><code>- (void)sendLocationToServerWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  {
      NSDictionary *params = @{
                               @"UserId"      : self.userId,
                               @"Latitude"    : self.latitude,
                               @"Longitude"   : self.longitude
                               }
  
      ServerManager *manager = [ServerManager sharedManager];
      [manager sendLocationToServerWithCompletion:^(BOOL success) {
  
          if (success)
          {
              completionHandler(UIBackgroundFetchResultNewData);
          }
          else
          {
              completionHandler(UIBackgroundFetchResultFailed);
          }
  
      }];
  }
  </code></pre>
  
  <p>I just can't understand how they all work together, will Apple approve that, is it even possible and where does the location background fetch goes into.</p>
  
  <p>Thanks in advance.</p>