Use this :
Fire your timer when app did entered into background in AppDelegate delegate method:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
if(!repeatTimer5.isValid)
{
repeatTimer5 = [NSTimer scheduledTimerWithTimeInterval:1.0 target: self
selector: @selector(toupdate) userInfo: nil repeats: YES];
}
}
- (void)toupdate
{
DLog(@"Testing timer Fired");
}
this will fire your timer method when app moved in foreground and will resumed when app moved in background.
If you still need to this timer will be fired in background mode then start BackgroundTask
- (void)applicationDidEnterBackground:(UIApplication *)application
{
if(!repeatTimer5.isValid)
{
[application beginBackgroundTaskWithExpirationHandler:^{
//your background expiration handler method
}];
repeatTimer5 = [NSTimer scheduledTimerWithTimeInterval:1.0 target: self
selector: @selector(toupdate) userInfo: nil repeats: YES];
}
}
- (void)toupdate
{
DLog(@"Testing timer Fired");
}
This will fire your timer when ur app is in background