diff --git a/Sample/ios/Runner/AppDelegate.swift b/Sample/ios/Runner/AppDelegate.swift index 6266644..c30b367 100644 --- a/Sample/ios/Runner/AppDelegate.swift +++ b/Sample/ios/Runner/AppDelegate.swift @@ -2,12 +2,15 @@ import Flutter import UIKit @main -@objc class AppDelegate: FlutterAppDelegate { +@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } } diff --git a/Sample/ios/Runner/Info.plist b/Sample/ios/Runner/Info.plist index da7fe9d..50fd288 100644 --- a/Sample/ios/Runner/Info.plist +++ b/Sample/ios/Runner/Info.plist @@ -4,6 +4,8 @@ CADisableMinimumFrameDurationOnPhone + CFBundleAllowMixedLocalizations + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -28,6 +30,27 @@ LSRequiresIPhoneOS + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + FlutterSceneDelegate + UISceneStoryboardFile + Main + + + + UIApplicationSupportsIndirectInputEvents UILaunchStoryboardName @@ -40,8 +63,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - CFBundleAllowMixedLocalizations - UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait diff --git a/Sample/lib/api/model/pg_codes.dart b/Sample/lib/api/model/pg_codes.dart index 1afbc97..be0929b 100644 --- a/Sample/lib/api/model/pg_codes.dart +++ b/Sample/lib/api/model/pg_codes.dart @@ -11,7 +11,9 @@ enum PGCode { apple_pay(code: "apple-pay", name: "Apple Pay"), tap_pg(code: "tap_pg", name: "Tag PG"), - ottu_sdk(code: "ottu_sdk", name: "Ottu Sdk"); + ottu_sdk(code: "ottu_sdk", name: "Ottu Sdk"), + cod(code: "cod", name: "cod"), + jamiawallet(code: "jamiawallet", name: "jamiawallet"); const PGCode({required this.code, required this.name, this.inverselyRelated}); diff --git a/Sample/lib/feature/home/home_screen.dart b/Sample/lib/feature/home/home_screen.dart index cf4ed5d..ef60b5a 100644 --- a/Sample/lib/feature/home/home_screen.dart +++ b/Sample/lib/feature/home/home_screen.dart @@ -287,18 +287,6 @@ class _HomeScreenState extends State { Text('Fail payment validation', style: TextStyle(color: Colors.red)), ], ), - Row( - children: [ - Checkbox( - checkColor: Colors.red, - value: state.failPaymentValidation ?? false, - onChanged: (bool? value) { - context.read().onFailPaymentValidation(value); - }, - ), - Text('Fail payment validation', style: TextStyle(color: Colors.red)), - ], - ), const SizedBox(height: 24), Divider(height: 2, thickness: 3), const Text('Payment methods:'), diff --git a/Sample/lib/feature/home/home_screen_cubit.dart b/Sample/lib/feature/home/home_screen_cubit.dart index 91a87f8..8b1b949 100644 --- a/Sample/lib/feature/home/home_screen_cubit.dart +++ b/Sample/lib/feature/home/home_screen_cubit.dart @@ -76,6 +76,8 @@ class HomeScreenCubit extends Cubit { //PGCode.urpay: true, PGCode.tamara: true, PGCode.tabby: true, + PGCode.cod: true, + PGCode.jamiawallet: true, }), ), ) { diff --git a/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift b/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift index c8fb694..87110a7 100644 --- a/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift +++ b/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift @@ -221,19 +221,25 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView { } func tryAttachController() { + Logger.sdk.info("tryAttachController") guard let pvc = self.paymentViewController else { return } - if let parentVC = UIApplication.shared.delegate?.window?? - .rootViewController as? FlutterViewController - { - parentVC.addChild(pvc) - _view.addCheckoutView(pvc.view) - pvc.didMove(toParent: parentVC) - Logger.sdk.info("Added to parent!") - } else { - Logger.sdk.info("Waiting for parent...") - DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { - self.tryAttachController() + if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene { + if let window = scene.windows.first(where: { $0.isKeyWindow }) { + let rootViewController = window.rootViewController + Logger.sdk.info("tryAttachController, pvc: \(rootViewController)") + if let parentVC = rootViewController as? FlutterViewController { + Logger.sdk.debug("tryAttachController, addChild PVC") + parentVC.addChild(pvc) + _view.addCheckoutView(pvc.view) + pvc.didMove(toParent: parentVC) + Logger.sdk.info("Added to parent!") + } else { + Logger.sdk.info("tryAttachController, PVC hasn found, waiting for parent...") + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + self.tryAttachController() + } + } } } } diff --git a/lib/src/checkout_widget.dart b/lib/src/checkout_widget.dart index cff4901..dcb353d 100644 --- a/lib/src/checkout_widget.dart +++ b/lib/src/checkout_widget.dart @@ -49,6 +49,9 @@ class _OttuCheckoutWidgetState extends State { @override void initState() { super.initState(); + if (kDebugMode) { + print("OttuCheckoutWidget.initState()"); + } _methodChannel.setMethodCallHandler(_handleChannelMethod); }