-
Notifications
You must be signed in to change notification settings - Fork 1
Added LocationManagerProtocol to support macOS and Linux #4
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
base: feature/services/gatt-services
Are you sure you want to change the base?
Added LocationManagerProtocol to support macOS and Linux #4
Conversation
|
|
||
| public class DarwinLocation: NSObject, LocationManagerProtocol { | ||
|
|
||
| internal private(set) var internalManager: CLLocationManager! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be let since this will never change
| self.locationManager = LocationManager() | ||
|
|
||
| #if os(macOS) | ||
| let serviceUUID = BluetoothUUID() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong, it should only be done on characteristics CoreBluetooth has blacklisted internally (because of collision with the ones a Mac advertises).
Sources/gattserver/Location.swift
Outdated
|
|
||
| extension LocationManagerProtocol { | ||
|
|
||
| public var didUpdateLocation: ((Double, Double) -> Void)? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason to provide default implementation, we want compiler error if this is not implemented
Sources/gattserver/Location.swift
Outdated
|
|
||
| public protocol LocationManagerProtocol: class { | ||
|
|
||
| var didUpdateLocation: ((Double, Double) -> Void)? { get set } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a struct like CLLocation
Sources/gattserver/Location.swift
Outdated
|
|
||
| var didUpdateLocation: ((Double, Double) -> Void)? { get set } | ||
|
|
||
| var locationServicesEnabled: Bool { get } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to use here self.locationManager?.accessQueue.async(flags: .barrier)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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