Actually in my app I'm starting more than two timers at different times. After certain time intervals I want notifications to fire. It's working fine when the app is on foreground but not in the background. How can I solve this?
Please help. Thanks!
You need to do following...
You need to turn on background mode.
In AppDelegate, Add this code to run app in background
Create a property
@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTask;
and then do following...
- (void)applicationDidEnterBackground:(UIApplication *)application {
self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
DLOG(@"End of tolerate time. Application should be suspended now if we do not ask more 'tolerance'");
}];
if (self.backgroundTask == UIBackgroundTaskInvalid) {
DLOG(@"This application does not support background mode");
} else {
//if application supports background mode, we'll see this log.
DLOG(@"Application will continue to run in background");
}
}
I hope it will help you.