Hi, I am creating an application with SwiftUI using CoreLocation. When I set the positioning system to kCLLocationAccuracyBest, the system does not appear. When I view it in GoogleMap, it sometimes shows me as if I am in a house instead of a street.
Please let me know how I can improve the system.
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate{
var locationManager : CLLocationManager?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool{
locationManager = CLLocationManager()
locationManager!.delegate = self
locationManager!.requestAlwaysAuthorization()
if CLLocationManager.locationServicesEnabled(){
locationManager!.desiredAccuracy = kCLLocationAccuracyBest
locationManager!.distanceFilter = 10
locationManager!.allowsBackgroundLocationUpdates = true
locationManager!.pausesLocationUpdatesAutomatically = false
locationManager!.startUpdatingLocation()
}
return true
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){
guard let newLocation = locations.last else {
return
}
let location: CLLocationCoordinate2D = CLLocationCoordinate2DMake(newLocation.coordinate.latitude, newLocation.coordinate.longitude)