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 FirebaseMessaging/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased
- [fixed] Fixed an issue where deep links were not correctly routed in apps utilizing scene
delegates. (#15987)

# 12.8.0
- [fixed] Fix missing database crash on launch. (#14880)

Expand Down
29 changes: 22 additions & 7 deletions FirebaseMessaging/Sources/FIRMessaging.m
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,35 @@ - (void)handleIncomingLinkIfNeededFromMessage:(NSDictionary *)message {
if (!application) {
return;
}
id<UIApplicationDelegate> 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<UISceneDelegate> sceneDelegate = (id<UISceneDelegate>)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<UIApplicationDelegate> 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){
Expand Down
Loading