You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to sometimes run my app on IP for mobile testing etc, and this used to work fine in Angular 16 since firebase would just ignore IPs but now, since Angular 20, I get:
TypeError: Cannot read properties of undefined (reading 'addEventListener')
eventually failing with
FirebaseError: Messaging: This browser doesn't support the API's required to use the Firebase SDK. (messaging/unsupported-browser).
But not before it halts the whole app and stops it rendering.
This should just not do anything when it detect a none 127.0.0.1 IP as it did before, seems like there has been a regression bug somewhere.
Hi @Sammaye, thanks for reporting this, and I'm sorry it went over a year without an answer.
You were right that this is a regression. What I found:
A page opened over plain HTTP at an IP address is not a secure context, so the browser gives it no navigator.serviceWorker. localhost is treated as secure, which is why it works there.
Firebase's getMessaging() uses navigator.serviceWorker without checking for it, and that is the TypeError you saw.
Through AngularFire 18, Messaging was null in a browser like that. 19.0.0 removed that check (Drop isSupported injection, bump rxfire #3588), and since then injecting Messaging there throws and stops the app from starting.
Messaging is null again in a browser with no service worker, so the app renders.
It will be released in AngularFire 22.0.0 (coming soon).
I'd normally point you at a canary build to try, but canary publishing is broken right now, so there isn't one with the fix yet.
When you do get the fix, check Messaging for null before calling onMessage or onRegistered, which throw when handed null.
Until you're on AngularFire 22.0.0
AngularFire 22.0.0 is for Angular 22, and you were on Angular 20, so here is something that works today. Ask Firebase's isSupported() first, and take Messaging from the injector only when the answer is yes:
isSupported and Messaging come from @angular/fire/messaging, and Injector and inject from @angular/core.
I ran this on Angular 20 with @angular/fire 20.0.1 over a LAN IP address. The app rendered with a clean console, and on localhost it still got a Messaging instance.
If it still misbehaves for you, with this or on 22.0.0 once it's out, let me know here and I'll look into it again.
Activity
[-]Running on IP stops Angular rendering[/-][+]Running FCM on IP stops Angular rendering[/+]armando-navarro commentedon Nov 27, 2026
Hi @Sammaye, thanks for reporting this, and I'm sorry it went over a year without an answer.
You were right that this is a regression. What I found:
navigator.serviceWorker.localhostis treated as secure, which is why it works there.getMessaging()usesnavigator.serviceWorkerwithout checking for it, and that is theTypeErroryou saw.Messagingwasnullin a browser like that. 19.0.0 removed that check (Drop isSupported injection, bump rxfire #3588), and since then injectingMessagingthere throws and stops the app from starting.#3852 fixes it, and its merge closed this issue:
Messagingisnullagain in a browser with no service worker, so the app renders.Messagingfornullbefore callingonMessageoronRegistered, which throw when handednull.Until you're on AngularFire 22.0.0
AngularFire 22.0.0 is for Angular 22, and you were on Angular 20, so here is something that works today. Ask Firebase's
isSupported()first, and takeMessagingfrom the injector only when the answer is yes:isSupportedandMessagingcome from@angular/fire/messaging, andInjectorandinjectfrom@angular/core.I ran this on Angular 20 with
@angular/fire20.0.1 over a LAN IP address. The app rendered with a clean console, and onlocalhostit still got aMessaginginstance.If it still misbehaves for you, with this or on 22.0.0 once it's out, let me know here and I'll look into it again.