You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.7 KiB
Swift
64 lines
2.7 KiB
Swift
import Flutter
|
|
import UIKit
|
|
import FirebaseCore
|
|
import FirebaseMessaging
|
|
import GoogleMaps
|
|
@main
|
|
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
|
func didInitializeImplicitFlutterEngine(_ engineBridge: any FlutterImplicitEngineBridge) {
|
|
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
|
|
|
// GMSServices.provideAPIKey("AIzaSyB6TERnxIr0yJ3qG4ULBZbu0sAD4tGqtng")
|
|
// FirebaseApp.configure()
|
|
// initializePlatformChannels()
|
|
|
|
}
|
|
|
|
override func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
) -> Bool {
|
|
GMSServices.provideAPIKey("AIzaSyB6TERnxIr0yJ3qG4ULBZbu0sAD4tGqtng")
|
|
// FirebaseApp.configure()
|
|
initializePlatformChannels()
|
|
// GeneratedPluginRegistrant.register(with: self)
|
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
}
|
|
func initializePlatformChannels(){
|
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
guard let self = self else { return }
|
|
|
|
// 1. Try accessing window via AppDelegate (legacy/single-window setup)
|
|
var controller = self.window?.rootViewController as? FlutterViewController
|
|
|
|
// 2. Fallback to UIWindowScene active window (modern iOS architecture)
|
|
if controller == nil {
|
|
controller = UIApplication.shared.connectedScenes
|
|
.compactMap { $0 as? UIWindowScene }
|
|
.flatMap { $0.windows }
|
|
.first(where: { $0.isKeyWindow })?
|
|
.rootViewController as? FlutterViewController
|
|
}
|
|
|
|
// 3. Perform initialization once FlutterViewController is available
|
|
if let mainViewController = controller {
|
|
HMGPenguinInPlatformBridge.initialize(flutterViewController: mainViewController)
|
|
} else {
|
|
print("⚠️ FlutterViewController not ready yet for initializePlatformChannels.")
|
|
}
|
|
}
|
|
|
|
|
|
// if let mainViewController = window?.rootViewController as? FlutterViewController{ // platform initialization suppose to be in foreground
|
|
// HMGPenguinInPlatformBridge.initialize(flutterViewController: mainViewController)
|
|
// }
|
|
|
|
}
|
|
|
|
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:Data){
|
|
// Messaging.messaging().apnsToken = deviceToken
|
|
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
|
|
}
|
|
}
|