From 667be2242e7a88d169d437fbde9f3dd64f520c2d Mon Sep 17 00:00:00 2001 From: Armando Navarro Date: Wed, 25 Nov 2026 13:57:56 -0800 Subject: [PATCH 1/2] docs(messaging): say Messaging can be null, and check in the example Messaging is null during server rendering, and with the fix for #3672 also in a browser with no service worker support. The page showed inject(Messaging) with no mention of either. The example service used the injected value in its constructor, so an app copied from it failed to render in those browsers. Add one sentence after the injection snippet, and null checks in the example's constructor, message$ and unregister. Refs #3672 --- docs/messaging.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/messaging.md b/docs/messaging.md index 62b8d9d08..774cd4d94 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -42,6 +42,8 @@ export class AppComponent { } ``` +`Messaging` is `null` during server rendering and in a browser with no service worker support, such as an iOS in-app browser or a page served over plain HTTP to another device, so check it before use. + # Create a Firebase Messaging Service Worker There are two parts to Firebase Messaging, a Service Worker and the DOM API. Angular Fire Messaging allows you to request permission, register this app instance, observe when it is registered or unregistered, and subscribe to messages on the DOM side. To register to receive notifications you need to set up the Service Worker. [The official Firebase documentation for setting up the details exactly how to do that](https://firebase.google.com/docs/cloud-messaging/js/client). @@ -96,10 +98,15 @@ export class FcmService { /* `onMessage` converted to an observable. Returns the unsubscribe function returned by * `onMessage` to stop the listener when the last subscriber unsubscribes. */ message$ = new Observable( - subscriber => onMessage(this.msg, (msg) => subscriber.next(msg)) + subscriber => this.msg ? onMessage(this.msg, (msg) => subscriber.next(msg)) : undefined ).pipe(tap((msg) => console.log("My Firebase Cloud Message", msg))); constructor(private msg: Messaging) { + // `Messaging` is null during server rendering and where the browser has no service workers. + if (!this.msg) { + return; + } + // Set listeners before calling `register` to avoid throwing. this.listenForRegistrationChanges(); this.registerForMessages(); @@ -144,6 +151,10 @@ export class FcmService { // Called from your app, for example when a user turns notifications off. async unregister() { + if (!this.msg) { + return; + } + // This calls the imported unregister, not this method. Class methods are not in lexical scope. await unregister(this.msg); } From d12005e7d2cdebef2d76cdad5b0533ff5562dd32 Mon Sep 17 00:00:00 2001 From: Armando Navarro Date: Wed, 25 Nov 2026 10:59:51 -0800 Subject: [PATCH 2/2] docs: say RemoteConfig is null during server rendering AngularFire creates no Remote Config instance on the server, so inject(RemoteConfig) returns null there while its type says RemoteConfig. The page showed the injection without mentioning it. --- docs/remote-config.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/remote-config.md b/docs/remote-config.md index 3add6c782..5bb8753e0 100644 --- a/docs/remote-config.md +++ b/docs/remote-config.md @@ -44,6 +44,8 @@ export class RemoteConfigComponent { } ``` +`RemoteConfig` is `null` during server rendering, so check it before use. + ## Firebase API AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.