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:

Implementing Infinite Scroll In Next Js With Server Actions

Implementing infinite scroll in Next.js with Server Actions

Infinite scrolling in Next.js no longer requires external libraries — Server Actions let us fetch initial data directly on the server.

Rahul Chhodde
Apr 19, 2024 â‹… 10 min read
Integrating Django Templates With React For Dynamic Webpages

Integrating Django templates with React for dynamic webpages

Create a dynamic demo blog site using Django and React to demonstrate Django’s server-side functionalities and React’s interactive UI.

Kayode Adeniyi
Apr 18, 2024 â‹… 7 min read
Using Aoi Js To Build A Bot For Discord

Using aoi.js to build a bot on Discord

Explore how the aoi.js library makes it easy to create Discord bots with useful functionalities for frontend applications.

Rahul Padalkar
Apr 17, 2024 â‹… 9 min read
Web Components Adoption Guide: Overview, Examples, And Alternatives

Web Components adoption guide: Overview, examples, and alternatives

Evaluate Web Components, a set of standards that allow you to create custom HTML tags for more reusable, manageable code.

Elijah Asaolu
Apr 16, 2024 â‹… 11 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