2022-03-17
1925
#firebase#react
Kapeel Kokane
31568
Mar 17, 2022 â‹… 6 min read

Push notifications with React and Firebase

Kapeel Kokane Coder by day, content creator by night, learner at heart!

Recent posts:

Exploring The Aha Stack: Astro, Htmx, Alpine — A Complete Tutorial With A Demo Project And Comparison To Other Stacks

Exploring the AHA stack: Tutorial, demo, and comparison

The AHA stack — Astro, htmx, and Alpine — is a solid web development stack for smaller apps that emphasize frontend speed and SEO.

Oyinkansola Awosan
May 3, 2024 â‹… 13 min read
Comparing Hattip Vs Express Js For Modern Application Development

Comparing Hattip vs. Express.js for modern app development

Explore what Hattip is, how it works, its benefits and key features, and the differences between Hattip and Express.js.

Antonello Zanini
May 2, 2024 â‹… 8 min read
Using React Shepherd To Build A Site Tour

Using React Shepherd to build a site tour

React Shepherd stands out as a site tour library due to its elegant UI and out-of-the-box, easy-to-use React Context implementation.

Onuorah Bonaventure
May 1, 2024 â‹… 14 min read
A Guide To Cookies In Next Js

A guide to cookies in Next.js

Cookies are crucial to web development. This article will explore how to handle cookies in your Next.js applications.

Georgey V B
Apr 30, 2024 â‹… 10 min read
View all posts

13 Replies to "Push notifications with React and Firebase"

  1. Hey, thanks for this guide.

    On Windows and Android this works as expected, however, on Safari (iOS) this just gives a white / blank screen.

    Obviously, Safari does not support Web push notifications but is there a way to exclude Messaging initialization if it’s not supported? As currently I suppose this is the root cause.

    What would be the required code adjustments to do this, can you suggest anything?

    Thanks,
    John

  2. hey,thanks for this code
    windows browser its working but mac-book chrome browser not receiving notification?

  3. Maybe its just me, but i tried duplicating this project on codesandbox enabling notifications for the site but I keep getting this Firebase Messaging Notification permission was not granted.

  4. Hi,

    Thanks for the article. How about registering the firebase service worker? Can’t find in the code the place where we register the “firebase-messaging-sw.js” by calling navigator.serviceWorker.register(‘/firebase-messaging-sw.js’)

  5. “Cannot read properties of undefined (reading ‘getProvider’)” got this error while implementing in app.js

  6. Hey! While I was adding the getToken function in firebase.js and importing firebase.js in app.js using the import statement: `import { getToken } form firebase.js`

    I got an error stating:- Identifier ‘getToken’ has already been declared. (23:13)

    Can you please help me out.
    Thanks

      1. The solution is just to change the name of the function to “fetchToken” (You can see this as well, if you open the github repo)
        If you just reference it as this, it will work

  7. What if i want to hide firebaseconfig because it can be easily accessible by anyone who will visit the application and can use the firebase config keys.

Leave a Reply