My application based on banking domain, need session handling. When application is idle (without any touch events after application open) have to calculate the time in background.
I handle the session maintenance when application entered into foreground and onResignInactive events in AppDelegate.
I need to handle application when live. Please help me to figure out this feature
If you were writing this as a web app, you would put the session timeout logic on the server, not the client. I would take the same approach with a mobile client also - have the server manage the session and timeout.
There's an answer for obj-C there: iOS perform action after period of inactivity (no user interaction)
So, at the application level, you keep a timer, and reset it on any event. Then you can do your business (like hiding any sensitive information) in the timer's handler.
Now, to the code.
First, you have to subclass UIApplication and make sure yours is instantiated:
This will ensure you have a timer running (caveat: the time starts only at the first event), that the timer will resets itself at any touch, and that a timeout will send a notification (named "timeoutNotification").
You now can listen to that notification and act on it (probably pushing a cover ViewController)
@Jason had a very good point that you shouldn't rely on client timeout for your session management but you should probably maintain a server state - and timeout - as well.