firebase cloud messaging in react code example
Example 1: how to deploy react app firebase
npm install -g firebase-tools
firebase login
firebase init
npm run build
firebase deploy
Example 2: import firebase cloud messaging web
import ReactDOM from "react-dom";import App from "./App";if ("serviceWorker" in navigator) { navigator.serviceWorker .register("./firebase-messaging-sw.js") .then(function(registration) { console.log("Registration successful, scope is:", registration.scope); }) .catch(function(err) { console.log("Service worker registration failed, error:", err); });}ReactDOM.render(, document.getElementById("root"));