iOS13-WiFi-Info
iOS13-WiFi-Info copied to clipboard
Return value for CLLocationManager.authorizationStatus()
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()
}
}
}