Issues with “Allow always” location in iOS 13

我们两清 提交于 2020-06-25 03:39:47

问题


I've an app which depends on the user's location. Until iOS 13 the app worked correctly but now it doesn' send the user's location.

I've tried to choose the option "While using app" and wait to the next prompt in order to choose "Allow always" but it doesn't work. Choosing "While using app" and going to settings for changing the option to "Allow always" doesn't work. (Both cases are the "official" answer of Apple in the documentation)

Any idea? Thanks


回答1:


From iOS 13 onwards, Apple replace "Always allow" to "Always once" from permission screen and moved "Always allow" in the settings.

If user select "Always once" then app will prompt location permission screen every time user launch the app.

If user select "While in use" then app will not prompt permission screen next time explicitly user need to travel to settings and give the permission.

Also receiving location update from switching to "While using app" to "Always Allow" from settings works for me.

Here is the properties I specifies

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




回答2:


This is a feature introduced in iOS 13 itself. As explained here: https://engineering.q42.nl/apple-location-permission-ios13/ If the user grants you ‘when in use’ permission and you try to scan for location in the background, only then the user will be presented a dialog to grant the background permission.

Seems quite buggy as of now, and is definitely not a good UX experience, but that is how it is as of now!




回答3:


This is very annoying from a MDM-perspective, since a location-app that must be used now constantly asks the user if it should still be allowed to use "Always allow". The admins need this to be on "Always allow" so we can track the iPads in case they get lost/stolen.



来源:https://stackoverflow.com/questions/58114750/issues-with-allow-always-location-in-ios-13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!