iOS app with location only works on iPhone and not on iPad, why?

40 views Asked by At

I build an iOS app with a map (locations) in Xcode version 15.3. The app works on a iPhone (real + simulated) very well, but if I downloaded the same app on the iPad (real + simulated), no location can't be found. I already checked the settings on my real iPad (enabled location services) but still nothing works. What goes wrong?

Added picture info.plist and the code locationmanager: info.plist info.plist

class LocationManager: NSObject, ObservableObject {
        private let locationManager = CLLocationManager()

  @Published var region = MKCoordinateRegion(
        center: .init(latitude: 37.334_900, longitude: -122.009_020),
        span: .init(latitudeDelta: 0.1, longitudeDelta: 0.1)
    )

    override init() {
        super.init()
        locationManager.requestAlwaysAuthorization()
        locationManager.requestWhenInUseAuthorization()
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.distanceFilter = kCLDistanceFilterNone
        locationManager.pausesLocationUpdatesAutomatically = true
        locationManager.startUpdatingLocation()
    }
}

extension LocationManager: CLLocationManagerDelegate {
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        guard let location = locations.last else { return }
        if (location.speed >= 0) {}
}

  func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
        degrees = -1 * newHeading.magneticHeading
    }
}
0

There are 0 answers