1

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

iamsult
  • 1,581
  • 1
  • 15
  • 21
pushpa
  • 573
  • 2
  • 7
  • 19

1 Answers1

4

You can only support location services.audio playing and VOIP services in your background.. If your app does not use any of these API's and their functions..than please don't waste your time doing it... Apple will not accept your app even if there is some method that makes this possible.

Shubhank
  • 21,721
  • 8
  • 65
  • 83