gpt4 book ai didi

ios - iOS 13 中的 "Allow always"位置问题

转载 作者:行者123 更新时间:2023-12-02 04:21:26 24 4
gpt4 key购买 nike

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

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

有什么想法吗?谢谢

最佳答案

从 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)")
}
}

关于ios - iOS 13 中的 "Allow always"位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58114750/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com