I am trying to log out and invalidate the user token after 5 minutes of inactivity.
When the application is on 'active' stage I am using the react-native-user-inactivity and set the timeForInactivity for 5 minutes. However, when the application runs on the background it has an expected behavior, especially when I set it to 5 minutes.
I was using 1 minute for testing and it was running fine, it used to call the API and invalidates the token correctly after the minute has passed. However, when I have increased it to 5 minutes, it was not firing until the application stage changed to 'active'.
I have similar behavior when I use the setTimeout for 5 minutes on AppState change event.
I have only tried it iOS but I have read somewhere that on Android it is giving an error when setting a timeout for more than 2 minutes. Is that correct?
What is the best way to invalidate the user token: 1. When the application is in the background 2. Just before closing the application?