Files
driver_tripz/ios/Runner/AppDelegate.swift
Hamza-Ayed 5a4664ed67 25-3/8/1
2025-03-08 19:35:09 +03:00

63 lines
2.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)
}
}