react-native-custom-tabs
react-native-custom-tabs copied to clipboard
Is there a way to know that user got back to the app?
I need to know if the user clicked on Back or X and got back to the app. Is there a way?
You can use AppState event Handler to know if your application has come back in foreground. For Functional component, register AppState.addEventListener('change', handleAppStateChange); in useEffect call and same thing in componentDidMount for class component.
this is my handleAppStateChange: const handleAppStateChange = async (nextAppState) => { console.log('AppState Changed: ', nextAppState); if (nextAppState === 'active') { setIsActive(true); } if(nextAppState === 'background'){ setIsActive(false); } }
Do not forget to unsubscribe for the event.