iOS 13 中“始终允许”位置的问题

Jua*_*njo 7 location objective-c locationmanager ios ios13

我有一个取决于用户位置的应用程序。在 iOS 13 之前,该应用程序运行正常,但现在它不会发送用户的位置。

我尝试选择“使用应用程序时”选项并等待下一个提示以选择“始终允许”,但它不起作用。选择“使用应用程序时”并转到将选项更改为“始终允许”的设置不起作用。(两种情况都是苹果在文档中的“官方”回答)

任何的想法?谢谢

iSa*_*man 5

从 iOS 13 开始,Apple 将权限屏幕中的“始终允许”替换为“始终一次”,并在设置中移动了“始终允许”。

如果用户选择“始终一次”,则每次用户启动应用程序时,应用程序都会提示位置权限屏幕。

如果用户选择“使用中”,那么下次应用程序将不会提示权限屏幕,用户需要前往设置并授予权限。

从设置中切换到“使用应用程序时”到“始终允许”的位置更新也对我有用。

这是我指定的属性

let locationManager = CLLocationManager()
locationManager.requestAlwaysAuthorization()
locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.delegate = self

.
.
.

extension AppDelegate: CLLocationManagerDelegate {

    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        switch status {
        case .authorizedAlways, .authorizedWhenInUse:
            locationManager.startUpdatingLocation()

        case .denied:
            print("Location permission denied")

        case .restricted:
            print("Location permission restricted")

        case .notDetermined:
            print("Location permission notDetermined")

        @unknown default:
            fatalError()
        }
    }

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        print("Location Update = \(String(describing: locations.first))")
    }

    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
        print("Location Error = \(error.localizedDescription)")
    }
}

Run Code Online (Sandbox Code Playgroud)