I am working on mobile application that needs to logout the user after some time of inactivity, using React-native. Firstly I tried to use react-native-user-inactivity, but I faced some troubles on Android and I decided to write custom logic for it. I use timer and pan responder to detect user gestures and tapings. When the user taps, the timer is reset. This is working fine when the app is on foreground. I want to logout the user even when the phone is locked. How can I execute function when the screen is locked?