Skip to content

Commit e8356ff

Browse files
Fix requestWhenInUseAuthorization issue #70
1 parent 7349a50 commit e8356ff

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.DS_Store

8 KB
Binary file not shown.

SwiftWeather/LocationService.swift

+15
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,19 @@ extension LocationService : CLLocationManagerDelegate {
4242
delegate?.locationDidFail(withError: swError)
4343
print("Error finding location: \(error.localizedDescription)")
4444
}
45+
46+
// requestWhenInUseAuthorization issue #70
47+
// Handle Authorization Status Changes
48+
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
49+
if status == .authorizedWhenInUse {
50+
locationManager.requestLocation()
51+
}
52+
}
53+
54+
@available(iOS 14.0, *)
55+
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
56+
if manager.authorizationStatus == .authorizedWhenInUse{
57+
locationManager.requestLocation()
58+
}
59+
}
4560
}

0 commit comments

Comments
 (0)