Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return value for CLLocationManager.authorizationStatus() #8

Open
youseokhwan opened this issue Jan 18, 2020 · 0 comments
Open

Return value for CLLocationManager.authorizationStatus() #8

youseokhwan opened this issue Jan 18, 2020 · 0 comments

Comments

@youseokhwan
Copy link

I need to detect network changes in background.
But there was a problem when requesting location permission.

CLLocationManager.authorizationStatus() returns .authorisedAlways when the device is set to “While Using the App”

Maybe because I don't know iOS and Swift well. What's wrong?

override func viewDidLoad() {
    super.viewDidLoad()

    if #available(iOS 13.0, *) {
        let status = CLLocationManager.authorizationStatus()
            
        if status == .authorizedAlways {
            print("Always")
            startWifiDetection()
        } else if status == .authorizedWhenInUse {
            print("While Using the App")
            locationManager.delegate = self
            locationManager.requestAlwaysAuthorization()
        } else {
            print("Never or Ask Next Time")
            locationManager.delegate = self
            locationManager.requestWhenInUseAuthorization()
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant