title: Automatically logout a user when app is inactive for the fixed duration of time
body: <p>I have requirement to automatically logout a user after some duration of time, and I am able to do that and logout app navigate to loginview but issue is that when I am on a view and performing some action like picking date from date picker or may I have other popup open at that time if app is logout then the popup or date picker or alert view  view displayed on login view.</p>
  
  <p>So my question is how can I remove that from loginview . This is the code I am using to logout my application. </p>
  
  <pre><code>@implementation MyApplication
  
     - (void)sendEvent:(UIEvent *)event {
  
         [super sendEvent:event];
  
      // Only want to reset the timer on a Began touch or an Ended touch, to reduce the number of timer resets.
  
      NSSet *allTouches = [event allTouches];
  
      if ([allTouches count] &gt; 0) {
  
          UITouchPhase phase = ((UITouch *)[allTouches anyObject]).phase;
          if (phase == UITouchPhaseBegan || phase == UITouchPhaseEnded)
                [self resetIdleTimer];
              NSLog(@"resetIdleTimer");
          [[NSUserDefaults standardUserDefaults]setValue:@"no" forKey:@"istouch"];
      }
  
  }
  
    -(void)resetIdleTimer {
  
      if (self.idleTimer) {
          [self.idleTimer invalidate];
      }
     NSTimeInterval timeInterval = [[[User currentUser]AutomaticLogoutTime] doubleValue]*60;
  
      if (timeInterval &gt; 0) {
          [[NSUserDefaults standardUserDefaults]setValue:@"yes" forKey:@"istouch"];
            self.idleTimer = [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(idleTimerExceeded) userInfo:nil repeats:NO] ;
  
      }
  }
  
  -(void)idleTimerExceeded {
  
      [[NSNotificationCenter defaultCenter] postNotificationName:@"DataUpdated"
                                                      object:self];
  }
  </code></pre>