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
{{ message }}
Repository navigation
ServiceWorker registration fails in Facebook/Instagram in-app browser on iOS #3630
The error occurs during the messaging service initialization when attempting to add an event listener to the ServiceWorker. The specific line causing the issue is:
The Facebook/Instagram in-app browser on iOS does not support or properly expose the ServiceWorker API, causing navigator.serviceWorker to be undefined. This issue persists even with the latest Angular 19 framework.
Impact
Firebase Cloud Messaging service initialization fails
Push notifications cannot be registered or received
Affects only users accessing the Angular 19 application through Facebook/Instagram in-app browser on iOS devices
+1 I have the same problem with an ionic app that uses @angular/fire/messaging. When the app is built for ios, starting the native ios app throws the same error.
Hi @veneliniliev and @aaltepet, thanks for the report and the follow-ups, and I'm sorry for the long wait.
What I found:
Firebase's getMessaging() uses navigator.serviceWorker without checking that it exists, which is the TypeError in the report.
Through AngularFire 18, Messaging was null in a browser with no service worker. 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 where the browser has no service worker, so the app starts.
It will be released in AngularFire 22.0.0 (coming soon), which is for Angular 22.
Canary publishing is broken right now, so there is no prerelease build with the fix to try yet.
Workaround until 22.0.0 is released
The isSupported() check @veneliniliev linked is the right idea. This is the form I tested, which takes Messaging from the injector only when Firebase says the browser supports it:
isSupported and Messaging come from @angular/fire/messaging, and Injector and inject from @angular/core. I ran it on Angular 20 and 21, on a page with no service worker, and the app rendered with a clean console.
With AngularFire 22.0.0 you can go back to injecting Messaging directly. Check it for null before calling onMessage or onRegistered, which throw when handed null.
Why this issue is still open
I tested the fix in Chrome on a page with no service worker support. I could not run it in the Facebook or Instagram in-app browser, or in an Ionic iOS build, so I don't want to call this fixed on my own say-so.
Once AngularFire 22.0.0 is out, could either of you check that the app starts there? If something else breaks in those browsers, I'd like to hear about it.
Activity
google-oss-bot commentedon Feb 27, 2025
This issue does not seem to follow the issue template. Make sure you provide all the required information.
aaltepet commentedon Mar 4, 2025
+1 I have the same problem with an ionic app that uses @angular/fire/messaging. When the app is built for ios, starting the native ios app throws the same error.
veneliniliev commentedon Mar 5, 2025
@aaltepet I use this solution: firebase/firebase-js-sdk#8817 (comment)
fix(messaging): inject null where the browser has no service worker (#…
armando-navarro commentedon Nov 27, 2026
Hi @veneliniliev and @aaltepet, thanks for the report and the follow-ups, and I'm sorry for the long wait.
What I found:
getMessaging()usesnavigator.serviceWorkerwithout checking that it exists, which is theTypeErrorin the report.Messagingwasnullin a browser with no service worker. 19.0.0 removed that check (Drop isSupported injection, bump rxfire #3588), and since then injectingMessagingthere throws and stops the app from starting.navigator.serviceWorker.#3852 should fix this:
Messagingisnullagain where the browser has no service worker, so the app starts.Workaround until 22.0.0 is released
The
isSupported()check @veneliniliev linked is the right idea. This is the form I tested, which takesMessagingfrom the injector only when Firebase says the browser supports it:isSupportedandMessagingcome from@angular/fire/messaging, andInjectorandinjectfrom@angular/core. I ran it on Angular 20 and 21, on a page with no service worker, and the app rendered with a clean console.With AngularFire 22.0.0 you can go back to injecting
Messagingdirectly. Check it fornullbefore callingonMessageoronRegistered, which throw when handednull.Why this issue is still open
I tested the fix in Chrome on a page with no service worker support. I could not run it in the Facebook or Instagram in-app browser, or in an Ionic iOS build, so I don't want to call this fixed on my own say-so.
Once AngularFire 22.0.0 is out, could either of you check that the app starts there? If something else breaks in those browsers, I'd like to hear about it.