@capacitor/geolocation 7.1.5-dev.4 → 7.1.5-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorGeolocation.podspec +1 -1
- package/Package.swift +1 -1
- package/ios/Sources/GeolocationPlugin/GeolocationCallbackManager.swift +1 -1
- package/ios/Sources/GeolocationPlugin/GeolocationPlugin.swift +1 -1
- package/ios/Sources/GeolocationPlugin/IONGLOCPositionModel+JSONTransformer.swift +1 -1
- package/package.json +1 -1
- package/ios/Sources/GeolocationPlugin/IONGeolocationLib/IONGLOCAuthorisation.swift +0 -26
- package/ios/Sources/GeolocationPlugin/IONGeolocationLib/IONGLOCAuthorisationRequestType.swift +0 -16
- package/ios/Sources/GeolocationPlugin/IONGeolocationLib/IONGLOCPositionModel.swift +0 -44
- package/ios/Sources/GeolocationPlugin/IONGeolocationLib/IONGLOCRequestOptionsModel.swift +0 -9
- package/ios/Sources/GeolocationPlugin/IONGeolocationLib/Publishers/IONGLOCManagerProtocols.swift +0 -45
- package/ios/Sources/GeolocationPlugin/IONGeolocationLib/Publishers/IONGLOCManagerWrapper.swift +0 -129
|
@@ -13,6 +13,6 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '14.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
|
|
16
|
+
s.dependency 'IONGeolocationLib', spec='2.0.0'
|
|
17
17
|
s.swift_version = '5.1'
|
|
18
18
|
end
|
package/Package.swift
CHANGED
|
@@ -11,7 +11,7 @@ let package = Package(
|
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
13
|
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0"),
|
|
14
|
-
.package(url: "https://github.com/ionic-team/ion-ios-geolocation.git", from: "
|
|
14
|
+
.package(url: "https://github.com/ionic-team/ion-ios-geolocation.git", from: "2.0.0")
|
|
15
15
|
],
|
|
16
16
|
targets: [
|
|
17
17
|
.target(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/geolocation",
|
|
3
|
-
"version": "7.1.5-dev.
|
|
3
|
+
"version": "7.1.5-dev.6",
|
|
4
4
|
"description": "The Geolocation API provides simple methods for getting and tracking the current position of the device using GPS, along with altitude, heading, and speed information if available.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import CoreLocation
|
|
2
|
-
|
|
3
|
-
public enum IONGLOCAuthorisation {
|
|
4
|
-
case notDetermined
|
|
5
|
-
case restricted
|
|
6
|
-
case denied
|
|
7
|
-
case authorisedAlways
|
|
8
|
-
case authorisedWhenInUse
|
|
9
|
-
|
|
10
|
-
init(from status: CLAuthorizationStatus) {
|
|
11
|
-
self = switch status {
|
|
12
|
-
case .notDetermined: .notDetermined
|
|
13
|
-
case .restricted: .restricted
|
|
14
|
-
case .denied: .denied
|
|
15
|
-
case .authorizedAlways: .authorisedAlways
|
|
16
|
-
case .authorizedWhenInUse: .authorisedWhenInUse
|
|
17
|
-
@unknown default: .notDetermined
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
extension CLLocationManager {
|
|
23
|
-
var currentAuthorisationValue: IONGLOCAuthorisation {
|
|
24
|
-
.init(from: authorizationStatus)
|
|
25
|
-
}
|
|
26
|
-
}
|
package/ios/Sources/GeolocationPlugin/IONGeolocationLib/IONGLOCAuthorisationRequestType.swift
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import CoreLocation
|
|
2
|
-
|
|
3
|
-
public enum IONGLOCAuthorisationRequestType {
|
|
4
|
-
case whenInUse
|
|
5
|
-
case always
|
|
6
|
-
|
|
7
|
-
func requestAuthorization(using locationManager: CLLocationManager) {
|
|
8
|
-
let requestAuthorisation = switch self {
|
|
9
|
-
case .whenInUse:
|
|
10
|
-
locationManager.requestWhenInUseAuthorization
|
|
11
|
-
case .always:
|
|
12
|
-
locationManager.requestAlwaysAuthorization
|
|
13
|
-
}
|
|
14
|
-
requestAuthorisation()
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import CoreLocation
|
|
2
|
-
|
|
3
|
-
public struct IONGLOCPositionModel: Equatable {
|
|
4
|
-
private(set) public var altitude: Double
|
|
5
|
-
private(set) public var course: Double
|
|
6
|
-
private(set) public var horizontalAccuracy: Double
|
|
7
|
-
private(set) public var latitude: Double
|
|
8
|
-
private(set) public var longitude: Double
|
|
9
|
-
private(set) public var speed: Double
|
|
10
|
-
private(set) public var timestamp: Double
|
|
11
|
-
private(set) public var verticalAccuracy: Double
|
|
12
|
-
|
|
13
|
-
private init(altitude: Double, course: Double, horizontalAccuracy: Double, latitude: Double, longitude: Double, speed: Double, timestamp: Double, verticalAccuracy: Double) {
|
|
14
|
-
self.altitude = altitude
|
|
15
|
-
self.course = course
|
|
16
|
-
self.horizontalAccuracy = horizontalAccuracy
|
|
17
|
-
self.latitude = latitude
|
|
18
|
-
self.longitude = longitude
|
|
19
|
-
self.speed = speed
|
|
20
|
-
self.timestamp = timestamp
|
|
21
|
-
self.verticalAccuracy = verticalAccuracy
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public extension IONGLOCPositionModel {
|
|
26
|
-
static func create(from location: CLLocation) -> IONGLOCPositionModel {
|
|
27
|
-
.init(
|
|
28
|
-
altitude: location.altitude,
|
|
29
|
-
course: location.course,
|
|
30
|
-
horizontalAccuracy: location.horizontalAccuracy,
|
|
31
|
-
latitude: location.coordinate.latitude,
|
|
32
|
-
longitude: location.coordinate.longitude,
|
|
33
|
-
speed: location.speed,
|
|
34
|
-
timestamp: location.timestamp.millisecondsSinceUnixEpoch,
|
|
35
|
-
verticalAccuracy: location.verticalAccuracy
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private extension Date {
|
|
41
|
-
var millisecondsSinceUnixEpoch: Double {
|
|
42
|
-
timeIntervalSince1970 * 1000
|
|
43
|
-
}
|
|
44
|
-
}
|
package/ios/Sources/GeolocationPlugin/IONGeolocationLib/Publishers/IONGLOCManagerProtocols.swift
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Combine
|
|
2
|
-
|
|
3
|
-
public protocol IONGLOCServicesChecker {
|
|
4
|
-
func areLocationServicesEnabled() -> Bool
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
public protocol IONGLOCAuthorisationHandler {
|
|
8
|
-
var authorisationStatus: IONGLOCAuthorisation { get }
|
|
9
|
-
var authorisationStatusPublisher: Published<IONGLOCAuthorisation>.Publisher { get }
|
|
10
|
-
|
|
11
|
-
func requestAuthorisation(withType authorisationType: IONGLOCAuthorisationRequestType)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public enum IONGLOCLocationError: Error {
|
|
15
|
-
case locationUnavailable
|
|
16
|
-
case timeout
|
|
17
|
-
case other(_ error: Error)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public protocol IONGLOCLocationHandler {
|
|
21
|
-
var currentLocation: IONGLOCPositionModel? { get }
|
|
22
|
-
var currentLocationPublisher: AnyPublisher<IONGLOCPositionModel, IONGLOCLocationError> { get }
|
|
23
|
-
var locationTimeoutPublisher: AnyPublisher<IONGLOCLocationError, Never> { get }
|
|
24
|
-
func updateConfiguration(_ configuration: IONGLOCConfigurationModel)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public protocol IONGLOCSingleLocationHandler: IONGLOCLocationHandler {
|
|
28
|
-
func requestSingleLocation(options: IONGLOCRequestOptionsModel)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public protocol IONGLOCMonitorLocationHandler: IONGLOCLocationHandler {
|
|
32
|
-
func startMonitoringLocation(options: IONGLOCRequestOptionsModel)
|
|
33
|
-
func startMonitoringLocation()
|
|
34
|
-
func stopMonitoringLocation()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public struct IONGLOCConfigurationModel {
|
|
38
|
-
private(set) var enableHighAccuracy: Bool
|
|
39
|
-
private(set) var minimumUpdateDistanceInMeters: Double?
|
|
40
|
-
|
|
41
|
-
public init(enableHighAccuracy: Bool, minimumUpdateDistanceInMeters: Double? = nil) {
|
|
42
|
-
self.enableHighAccuracy = enableHighAccuracy
|
|
43
|
-
self.minimumUpdateDistanceInMeters = minimumUpdateDistanceInMeters
|
|
44
|
-
}
|
|
45
|
-
}
|
package/ios/Sources/GeolocationPlugin/IONGeolocationLib/Publishers/IONGLOCManagerWrapper.swift
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import Combine
|
|
2
|
-
import CoreLocation
|
|
3
|
-
|
|
4
|
-
public typealias IONGLOCService = IONGLOCServicesChecker & IONGLOCAuthorisationHandler & IONGLOCSingleLocationHandler & IONGLOCMonitorLocationHandler
|
|
5
|
-
|
|
6
|
-
public struct IONGLOCServicesValidator: IONGLOCServicesChecker {
|
|
7
|
-
public init() {}
|
|
8
|
-
|
|
9
|
-
public func areLocationServicesEnabled() -> Bool {
|
|
10
|
-
CLLocationManager.locationServicesEnabled()
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
|
|
15
|
-
@Published public var authorisationStatus: IONGLOCAuthorisation
|
|
16
|
-
public var authorisationStatusPublisher: Published<IONGLOCAuthorisation>.Publisher { $authorisationStatus }
|
|
17
|
-
|
|
18
|
-
@Published public var currentLocation: IONGLOCPositionModel?
|
|
19
|
-
private var timeoutCancellable: AnyCancellable?
|
|
20
|
-
public var currentLocationPublisher: AnyPublisher<IONGLOCPositionModel, IONGLOCLocationError> {
|
|
21
|
-
Publishers.Merge($currentLocation, currentLocationForceSubject)
|
|
22
|
-
.dropFirst() // ignore the first value as it's the one set on the constructor.
|
|
23
|
-
.tryMap { location in
|
|
24
|
-
guard let location else { throw IONGLOCLocationError.locationUnavailable }
|
|
25
|
-
return location
|
|
26
|
-
}
|
|
27
|
-
.mapError { $0 as? IONGLOCLocationError ?? .other($0) }
|
|
28
|
-
.eraseToAnyPublisher()
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public var locationTimeoutPublisher: AnyPublisher<IONGLOCLocationError, Never> {
|
|
32
|
-
locationTimeoutSubject.eraseToAnyPublisher()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private let currentLocationForceSubject = PassthroughSubject<IONGLOCPositionModel?, Never>()
|
|
36
|
-
private let locationTimeoutSubject = PassthroughSubject<IONGLOCLocationError, Never>()
|
|
37
|
-
|
|
38
|
-
private let locationManager: CLLocationManager
|
|
39
|
-
private let servicesChecker: IONGLOCServicesChecker
|
|
40
|
-
|
|
41
|
-
private var isMonitoringLocation = false
|
|
42
|
-
|
|
43
|
-
public init(locationManager: CLLocationManager = .init(), servicesChecker: IONGLOCServicesChecker = IONGLOCServicesValidator()) {
|
|
44
|
-
self.locationManager = locationManager
|
|
45
|
-
self.servicesChecker = servicesChecker
|
|
46
|
-
self.authorisationStatus = locationManager.currentAuthorisationValue
|
|
47
|
-
|
|
48
|
-
super.init()
|
|
49
|
-
locationManager.delegate = self
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public func requestAuthorisation(withType authorisationType: IONGLOCAuthorisationRequestType) {
|
|
53
|
-
authorisationType.requestAuthorization(using: locationManager)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public func startMonitoringLocation(options: IONGLOCRequestOptionsModel) {
|
|
57
|
-
isMonitoringLocation = true
|
|
58
|
-
self.startTimer(timeout: options.timeout)
|
|
59
|
-
locationManager.startUpdatingLocation()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public func startMonitoringLocation() {
|
|
63
|
-
isMonitoringLocation = true
|
|
64
|
-
locationManager.startUpdatingLocation()
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public func stopMonitoringLocation() {
|
|
68
|
-
isMonitoringLocation = false
|
|
69
|
-
locationManager.stopUpdatingLocation()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public func requestSingleLocation(options: IONGLOCRequestOptionsModel) {
|
|
73
|
-
// If monitoring is active meaning the location service is already running
|
|
74
|
-
// and calling .requestLocation() will not trigger a new location update,
|
|
75
|
-
// we can just return the current location.
|
|
76
|
-
if isMonitoringLocation, let location = currentLocation {
|
|
77
|
-
currentLocationForceSubject.send(location)
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
self.startTimer(timeout: options.timeout)
|
|
81
|
-
self.locationManager.requestLocation()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private func startTimer(timeout: Int) {
|
|
85
|
-
timeoutCancellable?.cancel()
|
|
86
|
-
timeoutCancellable = nil
|
|
87
|
-
timeoutCancellable = Just(())
|
|
88
|
-
.delay(for: .milliseconds(timeout), scheduler: DispatchQueue.main)
|
|
89
|
-
.sink { [weak self] _ in
|
|
90
|
-
guard let self = self else { return }
|
|
91
|
-
self.locationTimeoutSubject.send(.timeout)
|
|
92
|
-
self.timeoutCancellable?.cancel()
|
|
93
|
-
self.timeoutCancellable = nil
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public func updateConfiguration(_ configuration: IONGLOCConfigurationModel) {
|
|
98
|
-
locationManager.desiredAccuracy = configuration.enableHighAccuracy ? kCLLocationAccuracyBest : kCLLocationAccuracyThreeKilometers
|
|
99
|
-
configuration.minimumUpdateDistanceInMeters.map {
|
|
100
|
-
locationManager.distanceFilter = $0
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public func areLocationServicesEnabled() -> Bool {
|
|
105
|
-
servicesChecker.areLocationServicesEnabled()
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
extension IONGLOCManagerWrapper: CLLocationManagerDelegate {
|
|
110
|
-
public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
|
|
111
|
-
authorisationStatus = manager.currentAuthorisationValue
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
|
115
|
-
timeoutCancellable?.cancel()
|
|
116
|
-
timeoutCancellable = nil
|
|
117
|
-
guard let latestLocation = locations.last else {
|
|
118
|
-
currentLocation = nil
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
currentLocation = IONGLOCPositionModel.create(from: latestLocation)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public func locationManager(_ manager: CLLocationManager, didFailWithError error: any Error) {
|
|
125
|
-
timeoutCancellable?.cancel()
|
|
126
|
-
timeoutCancellable = nil
|
|
127
|
-
currentLocation = nil
|
|
128
|
-
}
|
|
129
|
-
}
|