Added LocationManagerProtocol to support macOS and Linux#4
Added LocationManagerProtocol to support macOS and Linux#4carlos21 wants to merge 5 commits intofeature/services/gatt-servicesfrom
Conversation
|
|
||
| public class DarwinLocation: NSObject, LocationManagerProtocol { | ||
|
|
||
| internal private(set) var internalManager: CLLocationManager! |
There was a problem hiding this comment.
should be let since this will never change
| self.locationManager = LocationManager() | ||
|
|
||
| #if os(macOS) | ||
| let serviceUUID = BluetoothUUID() |
There was a problem hiding this comment.
this is wrong, it should only be done on characteristics CoreBluetooth has blacklisted internally (because of collision with the ones a Mac advertises).
|
|
||
| extension LocationManagerProtocol { | ||
|
|
||
| public var didUpdateLocation: ((Double, Double) -> Void)? { |
There was a problem hiding this comment.
No reason to provide default implementation, we want compiler error if this is not implemented
|
|
||
| public protocol LocationManagerProtocol: class { | ||
|
|
||
| var didUpdateLocation: ((Double, Double) -> Void)? { get set } |
There was a problem hiding this comment.
We need a struct like CLLocation
|
|
||
| var didUpdateLocation: ((Double, Double) -> Void)? { get set } | ||
|
|
||
| var locationServicesEnabled: Bool { get } |
There was a problem hiding this comment.
I think this should only exist on the Darwin version, and in any case should be isEnabled
| else { assertionFailure("Array always contains at least one object representing the current location."); return } | ||
|
|
||
| didUpdateLocation?(location.coordinate.latitude, location.coordinate.longitude) | ||
| self.locationManager?.accessQueue.async { [weak self] in |
There was a problem hiding this comment.
Don't you need to use here self.locationManager?.accessQueue.async(flags: .barrier)?
There was a problem hiding this comment.
sure, improve as you see fit.
Take a quick look please, just to check if the implementation is going well. It would be awesome if we can separate this and create a LocationKit (or something like that) for macOS, watchOS, tvOS, iOS and Linux xD