Hello sir, I want to log out automatically if user not interact in the app for certain time. I have given one minutes bellow the code . But problem is that how handle it that means from where i call it. please suggest me how to bellow code work .
var d = new Date();
var n = d.getTime(); //n in ms
$rootScope.idleEndTime = n+(1*60*1000); //set end time to 20 min from now
$document.find('body').on('mousemove keydown DOMMouseScroll mousewheel mousedown touchstart', checkAndResetIdle); //monitor events
$rootScope.checkAndResetIdle=function() //user did something
{
var d = new Date();
var n = d.getTime(); //n in ms
console.log(“Start Check Time”);
if (n>$rootScope.idleEndTime)
{
console.log("Session ended due to inactivity'");
$ionicPopup.alert({
title: 'Session Expired',
template:'Your Session Has Expired. Please Sign In Again.'
})
$state.go('tabs.home', {});
}
else
{
console.log("reset");
$rootScope.idleEndTime = n+(1*60*1000); //reset end time
}
}
advance thanks…