From 20e8560b84f02d026211e759e5b8033ce7858255 Mon Sep 17 00:00:00 2001 From: Daymon Date: Thu, 26 Mar 2026 12:05:18 -0500 Subject: [PATCH 1/3] add scene support to handleIncomingLinkIfNeededFromMessage --- FirebaseMessaging/Sources/FIRMessaging.m | 29 ++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/FirebaseMessaging/Sources/FIRMessaging.m b/FirebaseMessaging/Sources/FIRMessaging.m index f8a696516a2..8d6ead5561c 100644 --- a/FirebaseMessaging/Sources/FIRMessaging.m +++ b/FirebaseMessaging/Sources/FIRMessaging.m @@ -390,20 +390,35 @@ - (void)handleIncomingLinkIfNeededFromMessage:(NSDictionary *)message { if (!application) { return; } - id appDelegate = application.delegate; - SEL continueUserActivitySelector = - @selector(application:continueUserActivity:restorationHandler:); + // Use string literal to ensure compatibility with Xcode 26 and iOS 18 + NSString *browsingWebType = @"NSUserActivityTypeBrowsingWeb"; + NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:browsingWebType]; + userActivity.webpageURL = url; + + // first look for a connected scene that can handle the activity + for (UIScene *scene in application.connectedScenes) { + if (scene.activationState == UISceneActivationStateForegroundActive || + scene.activationState == UISceneActivationStateForegroundInactive) { + if ([scene.delegate respondsToSelector:@selector(scene:continueUserActivity:)]) { + id sceneDelegate = (id)scene.delegate; + [sceneDelegate scene:scene continueUserActivity:userActivity]; + return; + } + } + } + + // fallback to the app delegate when a matching scene delegate wasn't found // Due to FIRAAppDelegateProxy swizzling, this selector will most likely get chosen, whether or // not the actual application has implemented // |application:continueUserActivity:restorationHandler:|. A warning will be displayed to the user // if they haven't implemented it. + id appDelegate = application.delegate; + SEL continueUserActivitySelector = + @selector(application:continueUserActivity:restorationHandler:); + if ([NSUserActivity class] != nil && [appDelegate respondsToSelector:continueUserActivitySelector]) { - // Use string literal to ensure compatibility with Xcode 26 and iOS 18 - NSString *browsingWebType = @"NSUserActivityTypeBrowsingWeb"; - NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:browsingWebType]; - userActivity.webpageURL = url; [appDelegate application:application continueUserActivity:userActivity restorationHandler:^(NSArray *_Nullable restorableObjects){ From fbc44b292639ceb57767f0c0d086fb2ae5237a07 Mon Sep 17 00:00:00 2001 From: Daymon Date: Thu, 26 Mar 2026 12:29:05 -0500 Subject: [PATCH 2/3] Add changelog entry --- FirebaseMessaging/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FirebaseMessaging/CHANGELOG.md b/FirebaseMessaging/CHANGELOG.md index 9f2346bc2d3..3b500fbffd9 100644 --- a/FirebaseMessaging/CHANGELOG.md +++ b/FirebaseMessaging/CHANGELOG.md @@ -1,3 +1,7 @@ +# Unreleased +- [fixed] Fixed an issue where deep links were not correctly routed in apps utilizing scene + delegates. + # 12.8.0 - [fixed] Fix missing database crash on launch. (#14880) From 0f4f1e97a9b2d2cae5e0337873988973d8e9009a Mon Sep 17 00:00:00 2001 From: Daymon <17409137+daymxn@users.noreply.github.com> Date: Wed, 15 Apr 2026 12:40:39 -0500 Subject: [PATCH 3/3] Update changelog with PR number --- FirebaseMessaging/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FirebaseMessaging/CHANGELOG.md b/FirebaseMessaging/CHANGELOG.md index 3b500fbffd9..43b71e37230 100644 --- a/FirebaseMessaging/CHANGELOG.md +++ b/FirebaseMessaging/CHANGELOG.md @@ -1,6 +1,6 @@ # Unreleased - [fixed] Fixed an issue where deep links were not correctly routed in apps utilizing scene - delegates. + delegates. (#15987) # 12.8.0 - [fixed] Fix missing database crash on launch. (#14880)