There is no need of this code this will active your application in background for Little time you have to mention Required background modes in info.plist of the project and the value should be App registers for location updates.
only Set UIBackgroundModes location in info.plist and it works in background this may help you.
//In app deligate
#pragma mark -
#pragma mark GPS Service
//========== start GPS SERVICE ===========
-(void)startGpsService
{
locationManager=[[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyBest;
locationManager.distanceFilter=10.0;
[locationManager startUpdatingLocation];
[self performSelectorInBackground:@selector(sendDataToServer) withObject:nil];
}
#pragma mark -
#pragma mark CLLocation Manager Delegates
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[self performSelectorInBackground:@selector(sendDataToServer) withObject:nil];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// No need to do any thing
/* UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier bgTask = 0;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
}];
*/
}