Home IOS Development swift – IOS Location – didUpdateLocations not referred to as

swift – IOS Location – didUpdateLocations not referred to as

0
swift – IOS Location – didUpdateLocations not referred to as

[ad_1]

I’m attempting to get location. Concern is that
func locationManager(_ supervisor: CLLocationManager, didChangeAuthorization standing: CLAuthorizationStatus) and locationManager(_ supervisor: CLLocationManager, didUpdateLocations areas: [CLLocation]) are by no means referred to as.

I’m requested for permission. I grant it. Once I name startLocation second time:

    DispatchQueue.world(qos: .background).async {
        let gpsController = GPSController()
        gpsController.startLocation()
        
        sleep(10)
            DispatchQueue.major.async {
                gpsController.startLocation()
            }
    }

I can see that permission is granted.

import Basis
import CoreLocation

class GPSController : NSObject, CLLocationManagerDelegate{

let locationManager: CLLocationManager = CLLocationManager()
static var lastLocation : CLLocation? = nil


func startLocation(){
    locationManager.delegate = self
    
    // Sprawdź standing usług lokalizacyjnych
    if CLLocationManager.locationServicesEnabled() {
        swap locationManager.authorizationStatus {
        case .notDetermined:
            print("notDetermined")
            locationManager.requestWhenInUseAuthorization()
            break
        case .restricted, .denied:
            print("Denied")
            break
        case .authorizedWhenInUse, .authorizedAlways:
            locationManager.startUpdatingLocation()
            print("authorizedWhenInUse")
        case .approved:
            print("approved")
            break
        @unknown default:
            print("@unknown")
            break
        }
    } else {
        print("flip off")
    }
    
}

func locationManager(_ supervisor: CLLocationManager, didChangeAuthorization standing: CLAuthorizationStatus) {
    print("didChangeAuthorization")
    if supervisor.authorizationStatus == .authorizedWhenInUse {
        locationManager.startUpdatingLocation()
    }
}

func locationManager(_ supervisor: CLLocationManager, didUpdateLocations areas: [CLLocation]) {
    print("didChangeAuthorization")
    for currentLocation in areas{
        Loge("Location : (currentLocation)")
        GPSController.lastLocation = currentLocation
    }
}


func locationManager(_ supervisor: CLLocationManager, didFailWithError error: Error) {
    print("error")
}    

}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here