Skip to content

Commit

Permalink
Remove location protocol preventing delegate interop
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBCarter committed Nov 22, 2024
1 parent 0df5cee commit cb52cfe
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 81 deletions.
6 changes: 3 additions & 3 deletions Sources/XyoClient/Witness/Location/LocationService.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CoreLocation
import Foundation

public class LocationService: NSObject, CLLocationManagerDelegate, LocationServiceProtocol {
public class LocationService: NSObject, CLLocationManagerDelegate {
private let locationManager = CLLocationManager()
private var locationCompletion: ((Result<CLLocation, Error>) -> Void)?

Expand All @@ -23,15 +23,15 @@ public class LocationService: NSObject, CLLocationManagerDelegate, LocationServi
}

// CLLocationManagerDelegate methods
@objc public func locationManager(
public func locationManager(
_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]
) {
if let location = locations.last {
locationCompletion?(.success(location))
}
}

@objc public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
locationCompletion?(.failure(error))
}
}

This file was deleted.

20 changes: 1 addition & 19 deletions Sources/XyoClient/Witness/Location/LocationWitness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,8 @@ import CoreLocation
import Foundation

open class LocationWitness: WitnessModuleAsync {
private var _locationService: LocationServiceProtocol?

private var locationService: LocationServiceProtocol {
if let service = _locationService {
return service
} else {
let initialized = LocationService()
self._locationService = initialized
return initialized
}
}

override public init(account: AccountInstance? = nil) {
super.init(account: account)
}

public convenience init(locationService: LocationServiceProtocol) {
self.init(account: nil)
self._locationService = locationService
}
private var locationService = LocationService()

override open func observe(completion: @escaping ([Payload]?, Error?) -> Void) {
locationService.requestAuthorization()
Expand Down
52 changes: 0 additions & 52 deletions Tests/XyoClientTests/Witness/LocationWitness.swift

This file was deleted.

0 comments on commit cb52cfe

Please sign in to comment.