title: Check user is online in React native
body: <p>I have Social App and i want to check user is ONLINE or OFFLINE:</p>
  <p>I know about Appstate in react native and I have one page web JS HTML for manage it( Social App)</p>
  <p>so my Problem is how can i see user online in myAPP and i can see this in myWeb?</p>
  <p>I am having a workaround like this:</p>
  <pre><code>class AppStateExample extends Component {
    state = {
      appState: AppState.currentState
    };
  
    componentDidMount() {
      AppState.addEventListener(&quot;change&quot;, this._handleAppStateChange);
    }
  
    componentWillUnmount() {
      AppState.removeEventListener(&quot;change&quot;, this._handleAppStateChange);
    }
  
    _handleAppStateChange = nextAppState =&gt; {
      if (
        this.state.appState.match(/inactive|background/) &amp;&amp;
        nextAppState === &quot;active&quot;
      ) {
        console.log(&quot;App has come to the foreground!&quot;);
      }
      this.setState({ appState: nextAppState });
    };
  </code></pre>
  <p>as soon as I'm online =&gt; i will add status into firestore 1 data</p>
  <pre><code>db.collection(&quot;data&quot;).doc(&quot;userA&quot;).set(
  ....
  status:'online'
  ).then(() =&gt; {
      console.log(&quot;change status is sussecd&quot;);
  });
  </code></pre>
  <p>then in MyWeb</p>
  <pre><code> db.collectionGroup('User').where('status', '==','online').onSnapshot(user =&gt; {
            someQuery.....//
          })
  </code></pre>
  <p>Is there any other way?</p>