Skip to content

Commit

Permalink
Merge pull request #81 from deepanshux/fix/requestWhenInUseAuthorization
Browse files Browse the repository at this point in the history
Fix requestWhenInUseAuthorization issue #70
  • Loading branch information
JakeLin authored Sep 4, 2023
2 parents 7349a50 + e8356ff commit 57faf3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions SwiftWeather/LocationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,19 @@ extension LocationService : CLLocationManagerDelegate {
delegate?.locationDidFail(withError: swError)
print("Error finding location: \(error.localizedDescription)")
}

// requestWhenInUseAuthorization issue #70
// Handle Authorization Status Changes
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if status == .authorizedWhenInUse {
locationManager.requestLocation()
}
}

@available(iOS 14.0, *)
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
if manager.authorizationStatus == .authorizedWhenInUse{
locationManager.requestLocation()
}
}
}

0 comments on commit 57faf3d

Please sign in to comment.