Search code examples
firebase-cloud-messaging

FCM error: Service messaging is not available


import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import { getMessaging } from "firebase/messaging";

// Your web app's Firebase configuration
const firebaseConfig = {
  apiKey: "AIzaSyA0dAgRPZLlgULgnOp2MH_3xtVbWPs03Cg",
  authDomain: "u-63f99.firebaseapp.com",
  projectId: "u-63f99",
  storageBucket: "u-63f99.appspot.com",
  messagingSenderId: "884933400988",
  appId: "1:884933400988:web:0b7e0e37b0f23da236d059",
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const fireStore = getFirestore(app);
const messaging = getMessaging(app);
export { auth, fireStore, messaging };

i'm getting this error, i don't know why messaging service is missing while i installed firebase SDK


Solution

  • your problem is probably because you're testing this on localhost (http).

    if you look at the console logs you might notice beside that error something like: code: 'messaging/unsupported-browser'

    and cloud messaging only support https connections so you'd have to make your localhost run on https somehow to get it to work :)