How to detect inactivity in the foreground
I used AppState to detect state changes in an application. But this only works when the application is in background
, and when it is active
. But I need to control the time inactive
.
I only need this if the user is inactive in the foreground. But this state also works when the application is in a state background
.
This is my code for managing state:
AppState.addEventListener('change', state =>
{
var blockApp = setTimeout(function(){
if(inVerify){
self.goToVerify();
}
}, 1000);
console.log('AppState changed to', state);
switch(state){
case 'active':
clearTimeout(blockApp);
inVerify = false;
break;
case 'inactive':
var x;
break;
case 'background':
inVerify = true;
blockApp;
break;
default:
//nothing state or different state, error in app state
break;
}
}
);
How can I control my inactivity time?
+3
source to share
No one has answered this question yet
Check out similar questions: