I am trying to implement certain app feature when app goes to background. But i saw a strange issue that if i do NSLog after every 2 seconds using NSTimer in "applicationDidEnterBackground", using simulator it works, but when i tested it in actual device, it doesn't print. Below is my code from "AppDelegate.m":
- (void)printLog
{
NSLog(@"logging after 2 sec.");
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
bckTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(printLog) userInfo:nil repeats:YES];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[bckTimer invalidate];
}
Please let me know why it's happening like this and may be any tips you would like to share while working with background app feature execution.
Thanks