I have to make a react-native app (not using expo nor hooks) that can login into a user, read some simple info and then logout through a logout button or automatically due to inactivity.
I have no issues with the login, setting the timer, nor the logout button, however I have no idea of how to detect ‘inactivity’, is this posible with states? and how exactly?
2
Answers
You can use
import AsyncStorage from '@react-native-async-storage/async-storage';
So basically, whenever user visits the app, you can store the time in which user logged in.
like this
and then when user again comes back to visit the app, you can check for the difference in that time and the time stored in Async storage.
first
Hope it helps. feel free for doubts
General concensus seems to be to use PanResponder:
get user inactivity in react native
Check for Inactivity in a React Native App