Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions FirebaseInAppMessaging/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased
- [fixed] Fixed an issue where universal links were not correctly routed in apps utilizing scene
delegates. (#16083)

# 12.1.0
- [fixed] Fix Xcode 26 crash from missing `NSUserActivityTypeBrowsingWeb`
symbol. Note that this fix isn't in the 12.1.0 zip and Carthage
Expand Down
26 changes: 26 additions & 0 deletions FirebaseInAppMessaging/Sources/Runtime/FIRIAMActionURLFollower.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,35 @@ - (BOOL)followURLWithAppDelegateOpenURLActivity:(NSURL *)url {

// Try to handle the url as a universal link by triggering
// application:continueUserActivity:restorationHandler: on App's delegate object directly.
// Will also look for scene delegates in the foreground that implement scene:continueUserActivity:.
// @return YES if that delegate method is defined and seeing a YES being returned from
// trigging it
- (BOOL)followURLWithContinueUserActivity:(NSURL *)url {
// First try to find a scene delegate to trigger, falling back to app delegate
for (UIScene *scene in self.mainApplication.connectedScenes) {
if (scene.activationState == UISceneActivationStateForegroundActive ||
scene.activationState == UISceneActivationStateForegroundInactive) {
id<UISceneDelegate> sceneDelegate = (id<UISceneDelegate>)scene.delegate;
if ([sceneDelegate respondsToSelector:@selector(scene:continueUserActivity:)]) {
FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM240004",
@"Scene delegate responds to scene:continueUserActivity."
"Simulating action url opening from a web browser.");
// Use string literal to ensure compatibility with Xcode 26 and iOS 18
NSString *browsingWebType = @"NSUserActivityTypeBrowsingWeb";
NSUserActivity *userActivity =
[[NSUserActivity alloc] initWithActivityType:browsingWebType];
userActivity.webpageURL = url;

[sceneDelegate scene:scene continueUserActivity:userActivity];

// The scene delegate method doesn't return anything, so we assume the response is YES
FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM240005",
@"Scene handling action URL returns YES, no more further action taken");
return YES;
}
}
}

if (self.isContinueUserActivityMethodDefined) {
FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM240004",
@"App delegate responds to application:continueUserActivity:restorationHandler:."
Expand Down
Loading