In an Angular/Ionic project, where would I use the following attributes to appropriately handle my needs?
document.addEventListener('pause', actiontobeperformed, false);
document.addEventListener('resume', actiontobeperformed , false);
My needs are:
I am building an app that is protected, meaning that you can only view the content when:
you enter the correct access code your session has not timed out But when you go to Home, then I want somehow to record that the session is over and that the user needs to authenticate when he comes back in the app.
$(document).ready(function () {
document.addEventListener('pause', actiontobeperformed, false);
document.addEventListener('resume', actiontobeperformed , false);
});
In your js first line or in html inside script tag
The simplest way to achieve a functionalty like you describe would be like this:
After the User authenticated his Session with his credentials you set a value into the localStorage with localStorage.login=1;
for example.
You now add the eventlistener for pause like document.addEventListener('pause', actiontobeperformed, false);
and call the function actiontobeperformed
after that.
function actiontobeperformed() {
localStorage.login=0;
}
The only thing you still need is a function which checks the login status. Therefore you could use an if else statement
if (localStorage.login == 1) {
goto menu;
} else {
goto loginpage;
}