I want to alert user in IOS when they go to inactive status (but are not heading to background)....however when I run code below, it triggers also when user is going straight from active to background.
I dont want to trigger alert when user is trying to go direct to background from active
AppState.addEventListener('change', (nextAppState)=> {
if (nextAppState === 'background') {
console.log('going to background (ios + android)')
} else if (nextAppState === 'active' && this.state.appState !== 'inactive'){
console.log('going to foreground from background (not from inactive)')
} else if (nextAppState === 'inactive' && this.state.appState === 'active'){
Alert.alert('going to inactive from foreground in IOS');
}
this.setState({ appState: nextAppState });
});