Skip to content

Commit 2317776

Browse files
Kobikg78claude
andcommitted
fix(ios): fix getViewController under UIScene + bump Flutter min SDK
- getViewController: replaced deprecated UIApplication.delegate.window (returns nil under UIScene) with UIWindowScene lookup on iOS 13+, falling back to the AppDelegate window for older iOS versions. - pubspec.yaml: bumped Flutter minimum SDK from >=1.10.0 to >=3.38.0 as required by the Flutter plugin migration guide for adopting FlutterSceneLifeCycleDelegate. Addresses review comments on PR #438. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0d9216b commit 2317776

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

ios/Classes/AppsflyerSdkPlugin.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,20 @@ - (void)appDidBecomeActive {
906906

907907

908908
+ (FlutterViewController*) getViewController{
909-
UIViewController *topMostViewControllerObj = [[[UIApplication sharedApplication] delegate] window].rootViewController;
909+
UIWindow *window = nil;
910+
if (@available(iOS 13.0, *)) {
911+
for (UIWindowScene *scene in [UIApplication sharedApplication].connectedScenes) {
912+
if (scene.activationState == UISceneActivationStateForegroundActive) {
913+
window = scene.windows.firstObject;
914+
break;
915+
}
916+
}
917+
}
918+
if (window == nil) {
919+
window = [[[UIApplication sharedApplication] delegate] window];
920+
}
921+
UIViewController *topMostViewControllerObj = window.rootViewController;
910922
FlutterViewController *flutterViewController = (FlutterViewController *)topMostViewControllerObj;
911-
912923
return flutterViewController;
913924
}
914925

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ homepage: https://github.com/AppsFlyerSDK/flutter_appsflyer_sdk
66

77
environment:
88
sdk: '>=2.17.0 <4.0.0'
9-
flutter: ">=1.10.0"
9+
flutter: ">=3.38.0"
1010

1111
dependencies:
1212
flutter:

0 commit comments

Comments
 (0)