Improve interaction after changing location auth
- Auto-add Wi-Fi after granting location access - Show alert when location access is denied TODO: localize.
This commit is contained in:
parent
fbe7d776e7
commit
9b96707d5b
|
@ -349,12 +349,20 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
||||||
break
|
break
|
||||||
|
|
||||||
case .denied:
|
case .denied:
|
||||||
// TODO: alert when location denied
|
let alert = UIAlertController.asAlert(
|
||||||
|
L10n.App.Service.Cells.TrustedAddWifi.caption,
|
||||||
|
"You must allow location access to trust this Wi-Fi network. Go to iOS settings and review your location permissions for Passepartout."
|
||||||
|
)
|
||||||
|
alert.addCancelAction(L10n.Core.Global.ok)
|
||||||
|
alert.addPreferredAction("Settings") {
|
||||||
|
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
|
||||||
|
}
|
||||||
|
present(alert, animated: true, completion: nil)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
locationManager.delegate = self
|
||||||
locationManager.requestWhenInUseAuthorization()
|
locationManager.requestWhenInUseAuthorization()
|
||||||
// TODO: auto-invoke trustCurrentWiFi() again when location granted
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1318,6 +1326,14 @@ extension ServiceViewController: ProviderPresetViewControllerDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ServiceViewController: CLLocationManagerDelegate {
|
||||||
|
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
|
||||||
|
|
||||||
|
// can only change when calling this method, re-invoke
|
||||||
|
_ = trustCurrentWiFi()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
private extension ServiceViewController {
|
private extension ServiceViewController {
|
||||||
|
|
Loading…
Reference in New Issue