Client app setup to receive notifications

To allow your app to receive notifications in your browser, it will have to get permissions from the user. To do so, we will add a piece of code that will show a consent dialog to let the user grant your app permission to receive notifications in your browser.

We will add the componentWillMount() method to our index.jsx file present under the home directory, since we want to show the dialog once the user is successfully logged in to the app:

 componentWillMount() {      firebase.messaging().requestPermission()       .then(function() {        console.log('Permission granted.');        // you can write logic to get the registration token          // _this.getToken();       })       .catch(function(err) { console.log('Unable to get permission to ...

Get Serverless Web Applications with React and Firebase now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.