|
|
|
|
@ -4,22 +4,58 @@ import FirebaseCore
|
|
|
|
|
import FirebaseMessaging
|
|
|
|
|
import GoogleMaps
|
|
|
|
|
@main
|
|
|
|
|
@objc class AppDelegate: FlutterAppDelegate {
|
|
|
|
|
@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()
|
|
|
|
|
// FirebaseApp.configure()
|
|
|
|
|
initializePlatformChannels()
|
|
|
|
|
GeneratedPluginRegistrant.register(with: self)
|
|
|
|
|
// GeneratedPluginRegistrant.register(with: self)
|
|
|
|
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
|
|
|
}
|
|
|
|
|
func initializePlatformChannels(){
|
|
|
|
|
if let mainViewController = window?.rootViewController as? FlutterViewController{ // platform initialization suppose to be in foreground
|
|
|
|
|
HMGPenguinInPlatformBridge.initialize(flutterViewController: mainViewController)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|