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:

Understanding The Css Revert Layer Keyword, Part Of Css Cascade Layers

Understanding the CSS revert-layer keyword

In this article, we’ll explore CSS cascade layers — and, specifically, the revert-layer keyword — to help you refine your styling strategy.

Chimezie Innocent
Apr 24, 2024 â‹… 6 min read
Exploring Nushell, A Rust Powered, Cross Platform Shell

Exploring Nushell, a Rust-powered, cross-platform shell

Nushell is a modern, performant, extensible shell built with Rust. Explore its pros, cons, and how to install and get started with it.

Oduah Chigozie
Apr 23, 2024 â‹… 6 min read
Exploring Zed, A Newly Open Source Code Editor Written In Rust

Exploring Zed, an open source code editor written in Rust

The Zed code editor sets itself apart with its lightning-fast performance and cutting-edge collaborative features.

Nefe Emadamerho-Atori
Apr 22, 2024 â‹… 7 min read
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
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