I am working on an app that allows user to login with your username & password and do some work in the app.
However, if the user has been idle / not using the app for 5 minutes, I want to "lock" my logged in user's session and re-direct them to the login page.
So, the way to do this is to start a global timer (setInterval) when they successfully logged in to call a session validate function. Then subscribe to any touch event in the app to reset the timer. If the timer has elapsed > 300 seconds, lock user.
I was googling along those lines and found the XCode Objective-C equivalent: https://stackoverflow.com/a/309535
Is there way to achieve something like this in titanium appcelerator? i.e. listen to ALL events on the whole app, when they stop occurring for 5 minutes; i.e. user is idle on app, lock the app (redirect to a different view for e.g. login).
I tried to listen to application wide touchend
events to reset the timer and it did not work:
// alloy.js
Ti.App.addEventListener('touchend', function(e){
console.log('### touchend ###');
});