I created module `react-native-inactivity` for this purpose. By using this module you can actually get if the app is inactive for X ms. You can use in this way.
```js
import ReactNativeInactivity from "react-native-inactivity";
export default function App() {
return (
<View style={{ flex: 1 }}>
<ReactNativeInactivity
isActive={true}
onInactive={() => {//Do Logout or something like that}}
timeForInactivity={60000} //1 mint in ms
restartTimerOnActivityAfterExpiration={false}
loop={false}
style={{ flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "grey" }}>
<YOUR_NAV_HERE/>
</ReactNativeInactivity>
</View>
);
}
```
You can also manage other props according to your requirement.
If this solution helped you just thumbs up and give me a star at repository.
For more refer to: https://www.npmjs.com/package/react-native-inactivity
I created module `react-native-inactivity` for this purpose. By using this module you can actually get if the app is inactive for 1 minute. You can use in this way.
```js
import ReactNativeInactivity from "react-native-inactivity";
export default function App() {
const [showImage, setShowImage] = React.useState(false);
return (
<View style={{ flex: 1 }}>
<ReactNativeInactivity
isActive={true}
onInactive={() => setShowImage(true)}
timeForInactivity={60000} //1 mint in ms
restartTimerOnActivityAfterExpiration={false}
loop={false}
style={{ flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "grey" }}>
<YOUR_NAV_HERE/>
</ReactNativeInactivity>
{ showImage ? <YourImage /> : null }
</View>
);
}
```
You can also manage other props according to your requirement. Even After showing the image you can actually deactivate the timer through state if you wish.
If this solution helped you just thumbs up and give me a star at repository.
For more refer to: https://www.npmjs.com/package/react-native-inactivity