firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.76k stars 874 forks source link

Service messaging is not available #7707

Open lfernandes00 opened 8 months ago

lfernandes00 commented 8 months ago

Operating System

Windows 10

Browser Version

Chrome v118.0.5993.88

Firebase SDK Version

9.9.4

Firebase SDK Product:

Messaging

Describe your project's tooling

I have a NextJS app (v12)

Describe the problem

The problem is when i try to configure the firebase file, the following error is occuring:

Error: Service messaging is not available

image

I also have this error: image

Steps and code to reproduce issue

Firebase.ts:

import { initializeApp } from "firebase/app";
import { getMessaging, getToken } from "firebase/messaging";

const firebaseConfig = {
  apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
  authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
  projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
  storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
  messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGE_SENDER_ID,
  appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
  measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
};

const app = initializeApp(firebaseConfig);

const messaging = getMessaging(app);

PS: I've seen some threads that recommend downgrading firebase to v8, but I'd like to keep it in v9. Is there any way to fix this?

jbalidiong commented 8 months ago

Hi @lfernandes00, thanks for reaching out and apologies for the delay. I was able to replicate the behavior you've mentioned. Let me check what we can do for this issue or bring someone here that can provide more context about it. I’ll update this thread if I have any information to share.

zwu52 commented 8 months ago

The error is thrown after the checker here: https://github.com/firebase/firebase-js-sdk/blob/master/packages/messaging-compat/src/messaging-compat.ts#L71C2-L71C2.

@lfernandes00 can you check which statement(s) is evaluating to false?

richterrene commented 7 months ago

Chiming in here, we're facing the same issue after trying to upgrade from 7.17.0 to 10.5.2

image

Any advice / news on this one? Thanks a lot!

jayachandra9 commented 6 months ago

any fix for above issue,im facing the same with Error: Service messaging is not available "firebase": "^9.9.1","next": "13.2.4",

Scottie35 commented 4 months ago

Exact same issue here, still. Trying to move from 8.10.1 -> 10.8.0

gigallo commented 2 weeks ago

Hi

we have the same problem only when we build the angular project with "--configuration production" option. Any idea why and how to solve it?

thanks