import UIKit import Flutter import FirebaseCore import GoogleMaps import CoreLocation // ✅ استيراد CoreLocation لتحديث الموقع @main @objc class AppDelegate: FlutterAppDelegate, CLLocationManagerDelegate { var locationManager: CLLocationManager? override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GMSServices.provideAPIKey(Constants.googleMapsAPIKey) FirebaseApp.configure() GeneratedPluginRegistrant.register(with: self) if JailbreakDetection.isJailbroken() { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { self.showJailbreakAlert() } } // ✅ تفعيل تحديث الموقع فور تشغيل التطبيق // startLocationUpdates() return super.application(application, didFinishLaunchingWithOptions: launchOptions) } func startLocationUpdates() { locationManager = CLLocationManager() locationManager?.delegate = self locationManager?.desiredAccuracy = kCLLocationAccuracyBest locationManager?.allowsBackgroundLocationUpdates = true locationManager?.pausesLocationUpdatesAutomatically = false locationManager?.requestAlwaysAuthorization() // ✅ طلب إذن الموقع locationManager?.startUpdatingLocation() // ✅ بدء التحديث } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { guard let location = locations.last else { return } print("📍 Location updated: \(location.coordinate.latitude), \(location.coordinate.longitude)") } func showJailbreakAlert() { guard let rootVC = UIApplication.shared.keyWindow?.rootViewController else { return } let alert = UIAlertController( title: "تحذير أمني", message: "تم اكتشاف أن جهازك يحتوي على جيلبريك. لا يمكن تشغيل التطبيق على هذا الجهاز.", preferredStyle: .alert ) alert.addAction(UIAlertAction(title: "إنهاء التطبيق", style: .destructive) { _ in exit(0) }) rootVC.present(alert, animated: true, completion: nil) } }