I have a problem with device locking. If my app is running and device gets locked then my app is also not working. I want my app to work even if my device is locked.
My code is as follows:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
background = YES;
UIApplication *app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if (background) {
StressFreeAlarmViewController *alarmController=[[StressFreeAlarmViewController alloc] initWithNibName:@"StressFreeAlarmViewController" bundle:nil];
[alarmController setTimer:[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updatingApp) userInfo:nil repeats:YES]];
background=NO;
}
});
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
background = NO;
}
comment this line