I want to make an application that updates users location to my remote server in every xx minute, even the application is in background I have tried the following code
- (void)applicationDidEnterBackground:(UIApplication *)application
{
i=0;
UIApplication *app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
bgTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(backgroundTask:) userInfo:nil repeats:YES];
}
-(void)backgroundTask:(NSTimer*)timer{
i++;
NSLog(@"%s %d",__func__,i);
}
But the timer callback stops after around 10 minutes How can I make an application that continuously updates current location to my server