Skip to content

Commit 0d9216b

Browse files
Kobikg78claude
andcommitted
fix(ios): adopt FlutterSceneLifeCycleDelegate for UIScene deep link support
The plugin only implemented AppDelegate-based lifecycle methods for deep linking. Since Flutter 3.41 auto-migrates apps to UIScene by default, UIKit no longer calls application:openURL:options: or application:continueUserActivity: — routing everything through the scene delegate instead. This caused deep links to be silently dropped on iOS apps using Flutter 3.41+. Fix: - Adopt FlutterSceneLifeCycleDelegate in AppsflyerSdkPlugin - Register via [registrar addSceneDelegate:instance] (iOS 13+) - Add scene:openURLContexts: for warm-start URI-scheme deep links - Add scene:willConnectToSession:options: for cold-start URI-scheme deep links - Add scene:continueUserActivity: for Universal Links via UIScene Verified on iOS 18.4 simulator with Flutter 3.41.4. Both cold-start and warm-start deep link callbacks now reach the plugin correctly without requiring any app-side workaround. Fixes: DELIVERY-114618 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent dabf605 commit 0d9216b

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

ios/Classes/AppsflyerSdkPlugin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#import "AppsFlyerLib.h"
77
#endif
88

9-
@interface AppsflyerSdkPlugin: NSObject<FlutterPlugin>
9+
@interface AppsflyerSdkPlugin: NSObject<FlutterPlugin, FlutterSceneLifeCycleDelegate>
1010

1111
@property (readwrite, nonatomic) BOOL isManualStart;
1212

@@ -18,7 +18,7 @@
1818
@end
1919

2020
// Appsflyer JS objects
21-
#define kAppsFlyerPluginVersion @"6.17.8"
21+
#define kAppsFlyerPluginVersion @"6.17.9"
2222
#define afDevKey @"afDevKey"
2323
#define afAppId @"afAppId"
2424
#define afIsDebug @"isDebug"

ios/Classes/AppsflyerSdkPlugin.m

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
6868
[registrar addMethodCallDelegate:instance channel:channel];
6969
[registrar addMethodCallDelegate:instance channel:callbackChannel];
7070
[registrar addApplicationDelegate:instance];
71-
71+
if (@available(iOS 13.0, *)) {
72+
[registrar addSceneDelegate:instance];
73+
}
7274

7375
}
7476

@@ -947,10 +949,36 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
947949
// Open Universal Links
948950
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {
949951
[[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
950-
952+
951953
// Results of this are ORed and NO doesn't affect other delegate interceptors' result.
952954
return NO;
953955
}
954956

957+
#pragma mark - FlutterSceneLifeCycleDelegate
958+
959+
// UIScene-based URI-scheme deep links (iOS 13+, Flutter 3.41+ UIScene migration)
960+
- (BOOL)scene:(UIScene*)scene openURLContexts:(NSSet<UIOpenURLContext*>*)URLContexts API_AVAILABLE(ios(13.0)) {
961+
for (UIOpenURLContext *context in URLContexts) {
962+
[[AppsFlyerAttribution shared] handleOpenUrl:context.URL options:@{}];
963+
}
964+
return NO;
965+
}
966+
967+
// Cold-start URI-scheme deep links delivered via UISceneConnectionOptions (iOS 13+)
968+
- (BOOL)scene:(UIScene*)scene
969+
willConnectToSession:(UISceneSession*)session
970+
options:(UISceneConnectionOptions*)connectionOptions API_AVAILABLE(ios(13.0)) {
971+
for (UIOpenURLContext *context in connectionOptions.URLContexts) {
972+
[[AppsFlyerAttribution shared] handleOpenUrl:context.URL options:@{}];
973+
}
974+
return NO;
975+
}
976+
977+
// UIScene-based Universal Links (iOS 13+)
978+
- (BOOL)scene:(UIScene*)scene continueUserActivity:(NSUserActivity*)userActivity API_AVAILABLE(ios(13.0)) {
979+
[[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:nil];
980+
return NO;
981+
}
982+
955983

956984
@end

0 commit comments

Comments
 (0)