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

tvOS CLLocationManager is slightly different #747

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions Sources/Site/Utility/LocationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ extension CLAuthorizationStatus {
throw LocationAuthorizationError.restricted
case .denied:
throw LocationAuthorizationError.denied
case .authorizedAlways, .authorizedWhenInUse, .authorized:
case .authorizedAlways, .authorizedWhenInUse:
return true
#if !os(tvOS)
case .authorized:
return true
#endif
@unknown default:
fatalError("CLocationAuthorizationState unknown not streamable")
}
Expand All @@ -53,7 +57,9 @@ actor LocationManager {
access: Access = .inUse
) {
manager = CLLocationManager()
manager.activityType = activityType
#if !os(tvOS)
manager.activityType = activityType
#endif
manager.distanceFilter = distanceFilter
manager.desiredAccuracy = desiredAccuracy
self.access = access
Expand All @@ -72,12 +78,16 @@ actor LocationManager {

return await withCheckedContinuation { continuation in
delegate.authorizationStreamContinuation = continuation
switch access {
case .inUse:
#if !os(tvOS)
switch access {
case .inUse:
manager.requestWhenInUseAuthorization()
case .always:
manager.requestAlwaysAuthorization()
}
#else
manager.requestWhenInUseAuthorization()
case .always:
manager.requestAlwaysAuthorization()
}
#endif
}
}

Expand All @@ -92,7 +102,11 @@ actor LocationManager {
}

delegate.locationStreamContinuation = continuation
manager.startUpdatingLocation()
#if !os(tvOS)
manager.startUpdatingLocation()
#else
manager.requestLocation()
#endif
}
}

Expand Down