import UIKit import Flutter @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) let controller : FlutterViewController = window?.rootViewController as! FlutterViewController let locationServiceChannel = FlutterMethodChannel(name: "location", binaryMessenger: controller.binaryMessenger) locationServiceChannel.setMethodCallHandler { (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in if call.method == "isLocationServiceRunning" { result(self.isLocationServiceRunning()) } else { result(FlutterMethodNotImplemented) } } locationManager = CLLocationManager() locationManager?.delegate = self locationManager?.requestAlwaysAuthorization() locationManager?.startUpdatingLocation() return super.application(application, didFinishLaunchingWithOptions: launchOptions) } private func isLocationServiceRunning() -> Bool { guard let locationManager = locationManager else { return false } let isRunning = locationManager.monitoredRegions.count > 0 || locationManager.location != nil return isRunning } }