October 2017
Intermediate to advanced
302 pages
7h 27m
English
Chrome emits the beforeinstallprompt event directly before it displays the web app install banner. That's the event we will listen to. Like our other Firebase event listeners, let's add this to our App.js componentDidMount.
We'll create a method called listenForInstallBanner, and then call that method from within componentDidMount:
componentDidMount() { firebase.auth().onAuthStateChanged(user => { if (user) { this.setState({ user }); } else { this.props.history.push('/login'); } }); firebase .database() .ref('/messages') .on('value', snapshot => { this.onMessage(snapshot); if (!this.state.messagesLoaded) { this.setState({ messagesLoaded: true }); } }); this.listenForInstallBanner();}
listenForInstallBanner = () => ...
Read now
Unlock full access