mardi 3 mars 2015

Keep NSTimer running even application goes in background in ios

I want to perform particular task in background continuously even my application goes in background.


Here is the code which i tried. Timer is firing only once when it enters in background.



- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSTimer * timer = [NSTimer timerWithTimeInterval:2.0
target:self
selector:@selector(timerTicked)
userInfo:nil
repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:timer
forMode:NSDefaultRunLoopMode];
}

- (void) timerTicked
{
NSLog(@"Timer method");
}



Aucun commentaire:

Enregistrer un commentaire