I have implemented the long running process method in ios5. I want to fire some function for every 30 seconds or 1 minute while my application is in the background.I have written the code to execute the long running process in did enter background method, I can't able to execute timer function when it enter background. Where should i put my timer function, so that it should call target method, even it is in the background.
bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
// Clean up any unfinished task business by marking where you.
// stopped or ending the task outright.
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(targetMethod) userInfo:nil repeats:YES];
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
How to do this? Some sample code will be helpful.
Thanks Pushpa