Look at the AppState API in FB (Face Book)
He has 3 states on FB and 5 points. I see only 3 in FB, but the other 2 may or may not be excluded.
Active - the application runs in the foreground
background- The application runs in the background. The user is either in another application or on the main screen.
inactive - , , ,
Docs, .
, , . , , api.
,
if (this.state.appState.match(/inactive|background/) && nextAppState === 'active')
Facebooks , change listiner componentDidMount <26 > accourding .
import React, {Component} from 'react'
import {AppState, Text} from 'react-native'
class AppStateExample extends Component {
state = {
appState: AppState.currentState
}
componentDidMount() {
AppState.addEventListener('change', this._handleAppStateChange);
}
componentWillUnmount() {
AppState.removeEventListener('change', this._handleAppStateChange);
}
_handleAppStateChange = (nextAppState) => {
if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
console.log('App has come to the foreground!')
}
this.setState({appState: nextAppState});
}
render() {
return (
<Text>Current state is: {this.state.appState}</Text>
);
}
}