import Flutter import UIKit import YandexLoginSDK /// iOS 27 requires a UIScene lifecycle. Flutter 3.38 does not yet have /// `FlutterImplicitEngineDelegate`, so channels and URL handling are wired /// here after the scene creates the Flutter view. class SceneDelegate: FlutterSceneDelegate { override func scene( _ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions ) { super.scene(scene, willConnectTo: session, options: connectionOptions) registerCallChannels() handleConnectionOptions(connectionOptions) } override func sceneDidBecomeActive(_ scene: UIScene) { super.sceneDidBecomeActive(scene) registerCallChannels() } override func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { var handledCustomURL = false if let appDelegate = UIApplication.shared.delegate as? AppDelegate { for context in URLContexts { if appDelegate.handleOpenURL( context.url, sourceApplication: context.options.sourceApplication ) { handledCustomURL = true } } } if !handledCustomURL { super.scene(scene, openURLContexts: URLContexts) } } override func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { if YXLSdk.shared.processUserActivity(userActivity) { return } super.scene(scene, continue: userActivity) } private func registerCallChannels() { guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } appDelegate.registerCallChannels(from: flutterViewController) } private var flutterViewController: FlutterViewController? { if let controller = window?.rootViewController as? FlutterViewController { return controller } for scene in UIApplication.shared.connectedScenes { guard let windowScene = scene as? UIWindowScene else { continue } for sceneWindow in windowScene.windows { if let controller = sceneWindow.rootViewController as? FlutterViewController { return controller } } } return nil } private func handleConnectionOptions(_ options: UIScene.ConnectionOptions) { guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } for context in options.urlContexts { _ = appDelegate.handleOpenURL( context.url, sourceApplication: context.options.sourceApplication ) } for activity in options.userActivities { if YXLSdk.shared.processUserActivity(activity) { continue } } } }