From 273491cab21df31d8f0e79e50aee31174ca2f0d4 Mon Sep 17 00:00:00 2001 From: jobweegink <47540520+jobweegink@users.noreply.github.com> Date: Thu, 3 Sep 2026 12:49:53 +0200 Subject: [PATCH] fix(auth, iOS): guard URL handlers when no FirebaseApp is configured `application(_:open:options:)` and `scene(_:openURLContexts:)` call `Auth.auth()` unconditionally. When the default FirebaseApp has not been configured yet (an app that calls `Firebase.initializeApp` from Dart with explicit options after start-up, or a debug build that never initialises Firebase), `Auth.auth()` hits FirebaseAuth's fatal "The default FirebaseApp instance must be configured before the default Auth instance can be initialized" and the process dies on any URL delivered through the app's URL schemes. `ensureAPNSTokenSetting()` in the same file already guards with `FirebaseApp.app() != nil`; this applies the same guard to the two URL handlers, returning `false` (not handled) when no app is configured. --- .../Sources/firebase_auth/FLTFirebaseAuthPlugin.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.swift b/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.swift index 1de3d256a8f5..d65a559cbbf3 100644 --- a/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.swift +++ b/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.swift @@ -186,11 +186,15 @@ public class FLTFirebaseAuthPlugin: NSObject, FlutterPlugin, FLTFirebasePluginPr open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:] ) -> Bool { - Auth.auth().canHandle(url) + // Auth.auth() traps when no FirebaseApp has been configured yet (e.g. an + // app that initialises Firebase from Dart-side options after start-up). + guard FirebaseApp.app() != nil else { return false } + return Auth.auth().canHandle(url) } public func scene(_ scene: UIScene, openURLContexts urlContexts: Set) -> Bool { + guard FirebaseApp.app() != nil else { return false } for urlContext in urlContexts where Auth.auth().canHandle(urlContext.url) { return true }