0

My app is not updating the information from the web services when the app is running in the background.

-(void)onTick:(NSTimer *)timer {
    [self parseData];
    [self.tableView reloadData];

}
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSDate *d = [NSDate dateWithTimeIntervalSinceNow: 60.0];
    NSTimer *t = [[NSTimer alloc] initWithFireDate: d
                                          interval: 30.0
                                            target: self
                                          selector:@selector(onTick:)
                                          userInfo:nil repeats:YES];

NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer:t forMode: NSDefaultRunLoopMode];

}

If the app is visible than everything goes smooth, as soon as it gets put into the background it does not update the data until i bring the app to the foreground again.

Any ideas or suggestions to what is causing this?

Much appreciated.

Jamie Taylor
  • 4,709
  • 5
  • 44
  • 66
user3396301
  • 101
  • 1
  • 3
  • 8
  • 3
    possible duplicate of [iOS: Keep application running in background](http://stackoverflow.com/questions/10674004/ios-keep-application-running-in-background) – tommyo Mar 30 '14 at 21:42

1 Answers1

0

To save resources on iOS device, the Operating System doesn't not update/draw UIView that are not visible.

Also, unless your application request permissions, your app will be suspended in the background.

From Apple Docs The View Drawing Cycle

View drawing occurs on an as-needed basis. When a view is first shown, or when all or part of it becomes visible due to layout changes, the system asks the view to draw its contents.

Black Frog
  • 11,595
  • 1
  • 35
  • 66