diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index 5d0becc..9014614 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -1,51 +1,13 @@
import UIKit
import Flutter
-import CoreLocation
@UIApplicationMain
-@objc class AppDelegate: FlutterAppDelegate, CLLocationManagerDelegate {
- let locationManager = CLLocationManager()
-
- var isSupportingLocationUpdates = false
+@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
- isSupportingLocationUpdates = CLLocationManager.significantLocationChangeMonitoringAvailable()
- if (isSupportingLocationUpdates) {
- locationManager.requestAlwaysAuthorization()
- if #available(iOS 9.0, *) {
- locationManager.allowsBackgroundLocationUpdates = true
- }
- locationManager.delegate = self
- startLocationUpdate()
- }
-
- let controller = window?.rootViewController as! FlutterViewController
- let locationChannel = FlutterMethodChannel(name: "location", binaryMessenger: controller.binaryMessenger)
-
- locationChannel.setMethodCallHandler({
- [weak self] (call: FlutterMethodCall, result: FlutterResult) -> Void in
- // Note: this method is invoked on the UI thread.
-
- if !(self?.isSupportingLocationUpdates ?? false) {
- result(FlutterError(code: "Unavailable",
- message: "Location is not available",
- details: nil))
- return
- }
-
- if call.method == "getLocation" {
- result(self?.getLocation())
- } else if call.method == "startLocationUpdates" {
- self?.startLocationUpdate()
- } else if call.method == "stopLocationUpdates" {
- self?.stopLocationUpdate()
- } else {
- result(FlutterMethodNotImplemented)
- }
- })
// Messaging
if #available(iOS 10.0, *) {
@@ -55,28 +17,4 @@ import CoreLocation
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
-
- func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
- locations.forEach { (location) in
- LocationsStorage.shared.saveLocationOnDisk(location: Location(location.coordinate, date: location.timestamp))
- }
- }
-
- private func getLocation() -> [String] {
- let encoder = JSONEncoder()
- return LocationsStorage.shared.locations.map { (location) -> String in
- guard let data = try? encoder.encode(location) else {
- return ""
- }
- return String(data: data, encoding: .utf8)!
- }
- }
-
- private func startLocationUpdate() {
- locationManager.startMonitoringSignificantLocationChanges()
- }
-
- private func stopLocationUpdate() {
- locationManager.stopMonitoringSignificantLocationChanges()
- }
}
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 7dcbb79..d2e0adb 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -26,11 +26,6 @@
NSCameraUsageDescription
Myhealth camera permission for qr scanner
- UIBackgroundModes
-
- location
- remote-notification
-
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile