Keep application in active state infinitely in background
Hi all
Now I am performing location services in iOs. Application has to saving user 's location even if it is working in background !
I tried to use applicationDidEnterBackground but the application can keep active state (when it can save user 's location ) only in 10 minutes.
Please advice me to solve this problem.
Thank you very much !
The following is my listing :
-------------
- (void) applicationDidEnterBackground:(UIApplication *)application
{
//run timer in background .
self.bgTask= [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:self.bgTask];
self.bgTask = UIBackgroundTaskInvalid;
}];
// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//startingMultitaskingTimer
[self performSelector:@selector(TimerExecution) withObject:nil] ;
[application endBackgroundTask:self.bgTask];
self.bgTask = UIBackgroundTaskInvalid;
});
}
- (void) TimerExecution
{
if(self.timer) {
[self.timer invalidate];
self.timer = nil;
}
self.timer = [NSTimer scheduledTimerWithTimeInterval:2 target:APPDELEGATE.viewController.locationManager selector:@selector(updateTracklog) userInfo:nil repeats:YES];
}
updateTracklog is function that execute according to timer for saving coordinates .
iPad, iOS 6