- (void)applicationWillResignActive:(UIApplication *)application {
    
    background_task =[[UIApplication sharedApplication] beginBackgroundTaskWithName:@"i360Doc" expirationHandler:^
    {
        NSLog(@"EndDate = %@",[NSDate date]);
        
        [application endBackgroundTask: background_task];
        background_task = UIBackgroundTaskInvalid;
        
    }];
    
    
    if(!timer)
    {
        timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(startTimer) userInfo:nil repeats:YES];
    }
    
    NSLog(@"startDate = %@",[NSDate date]);
    
    
}
-(void)startTimer
{
    double TimeRemaining = [[UIApplication sharedApplication] backgroundTimeRemaining];
    NSLog(@"Background time Remaining: %f",TimeRemaining);
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
    [application endBackgroundTask: background_task];
    background_task = UIBackgroundTaskInvalid;
}