@capacitor/geolocation 7.1.5-dev.1 → 7.1.5-dev.2
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/ios/Sources/GeolocationPlugin/IONGeolocationLib/Publishers/IONGLOCManagerProtocols.swift
CHANGED
|
@@ -13,7 +13,6 @@ public protocol IONGLOCAuthorisationHandler {
|
|
|
13
13
|
|
|
14
14
|
public enum IONGLOCLocationError: Error {
|
|
15
15
|
case locationUnavailable
|
|
16
|
-
//TODO changes here
|
|
17
16
|
case timeout
|
|
18
17
|
case other(_ error: Error)
|
|
19
18
|
}
|
|
@@ -26,12 +25,10 @@ public protocol IONGLOCLocationHandler {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
public protocol IONGLOCSingleLocationHandler: IONGLOCLocationHandler {
|
|
29
|
-
//TODO changes here
|
|
30
28
|
func requestSingleLocation(timeout: Int?)
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
public protocol IONGLOCMonitorLocationHandler: IONGLOCLocationHandler {
|
|
34
|
-
//TODO changes here
|
|
35
32
|
func startMonitoringLocation(timeout: Int?)
|
|
36
33
|
func startMonitoringLocation()
|
|
37
34
|
func stopMonitoringLocation()
|
package/ios/Sources/GeolocationPlugin/IONGeolocationLib/Publishers/IONGLOCManagerWrapper.swift
CHANGED
|
@@ -14,10 +14,9 @@ public struct IONGLOCServicesValidator: IONGLOCServicesChecker {
|
|
|
14
14
|
public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
|
|
15
15
|
@Published public var authorisationStatus: IONGLOCAuthorisation
|
|
16
16
|
public var authorisationStatusPublisher: Published<IONGLOCAuthorisation>.Publisher { $authorisationStatus }
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
@Published public var currentLocation: IONGLOCPositionModel?
|
|
19
19
|
private var timeoutCancellable: AnyCancellable?
|
|
20
|
-
|
|
21
20
|
public var currentLocationPublisher: AnyPublisher<IONGLOCPositionModel, IONGLOCLocationError> {
|
|
22
21
|
Publishers.Merge($currentLocation, currentLocationForceSubject)
|
|
23
22
|
.dropFirst() // ignore the first value as it's the one set on the constructor.
|
|
@@ -40,26 +39,23 @@ public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
|
|
|
40
39
|
private let servicesChecker: IONGLOCServicesChecker
|
|
41
40
|
|
|
42
41
|
private var isMonitoringLocation = false
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
|
|
45
43
|
public init(locationManager: CLLocationManager = .init(), servicesChecker: IONGLOCServicesChecker = IONGLOCServicesValidator()) {
|
|
46
44
|
self.locationManager = locationManager
|
|
47
45
|
self.servicesChecker = servicesChecker
|
|
48
46
|
self.authorisationStatus = locationManager.currentAuthorisationValue
|
|
49
|
-
|
|
47
|
+
|
|
50
48
|
super.init()
|
|
51
49
|
locationManager.delegate = self
|
|
52
50
|
}
|
|
53
|
-
|
|
51
|
+
|
|
54
52
|
public func requestAuthorisation(withType authorisationType: IONGLOCAuthorisationRequestType) {
|
|
55
53
|
authorisationType.requestAuthorization(using: locationManager)
|
|
56
54
|
}
|
|
57
|
-
|
|
55
|
+
|
|
58
56
|
public func startMonitoringLocation(timeout: Int? = nil) {
|
|
59
57
|
let timeoutValue = timeout ?? 5000
|
|
60
58
|
isMonitoringLocation = true
|
|
61
|
-
|
|
62
|
-
print("======================> startMonitoringLocation timeout: ", timeoutValue)
|
|
63
59
|
self.startTimer(timeout: timeoutValue)
|
|
64
60
|
locationManager.startUpdatingLocation()
|
|
65
61
|
}
|
|
@@ -67,20 +63,17 @@ public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
|
|
|
67
63
|
public func startMonitoringLocation() {
|
|
68
64
|
isMonitoringLocation = true
|
|
69
65
|
locationManager.startUpdatingLocation()
|
|
70
|
-
print("======================> startMonitoringLocation sem timer ")
|
|
71
66
|
}
|
|
72
|
-
|
|
67
|
+
|
|
73
68
|
public func stopMonitoringLocation() {
|
|
74
69
|
isMonitoringLocation = false
|
|
75
70
|
locationManager.stopUpdatingLocation()
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
//TODO changes here
|
|
79
73
|
public func requestSingleLocation(timeout: Int? = nil) {
|
|
80
74
|
// Fallback to default timeout (5000) when the parameter is nil,
|
|
81
75
|
// since optional defaults in Swift don't apply when nil is explicitly passed.
|
|
82
76
|
let timeoutValue = timeout ?? 5000
|
|
83
|
-
|
|
84
77
|
// If monitoring is active meaning the location service is already running
|
|
85
78
|
// and calling .requestLocation() will not trigger a new location update,
|
|
86
79
|
// we can just return the current location.
|
|
@@ -88,10 +81,8 @@ public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
|
|
|
88
81
|
currentLocationForceSubject.send(location)
|
|
89
82
|
return
|
|
90
83
|
}
|
|
91
|
-
|
|
92
84
|
self.startTimer(timeout: timeoutValue)
|
|
93
85
|
self.locationManager.requestLocation()
|
|
94
|
-
print("======================> requestLocation")
|
|
95
86
|
}
|
|
96
87
|
|
|
97
88
|
private func startTimer(timeout: Int) {
|
|
@@ -101,9 +92,7 @@ public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
|
|
|
101
92
|
.delay(for: .milliseconds(timeout), scheduler: DispatchQueue.main)
|
|
102
93
|
.sink { [weak self] _ in
|
|
103
94
|
guard let self = self else { return }
|
|
104
|
-
print("======================> Native lib: timeout triggered (\(timeout)ms)")
|
|
105
95
|
self.locationTimeoutSubject.send(.timeout)
|
|
106
|
-
print("======================> timeoutCancellable 4")
|
|
107
96
|
self.timeoutCancellable?.cancel()
|
|
108
97
|
self.timeoutCancellable = nil
|
|
109
98
|
}
|
|
@@ -115,7 +104,7 @@ public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
|
|
|
115
104
|
locationManager.distanceFilter = $0
|
|
116
105
|
}
|
|
117
106
|
}
|
|
118
|
-
|
|
107
|
+
|
|
119
108
|
public func areLocationServicesEnabled() -> Bool {
|
|
120
109
|
servicesChecker.areLocationServicesEnabled()
|
|
121
110
|
}
|
|
@@ -125,25 +114,18 @@ extension IONGLOCManagerWrapper: CLLocationManagerDelegate {
|
|
|
125
114
|
public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
|
|
126
115
|
authorisationStatus = manager.currentAuthorisationValue
|
|
127
116
|
}
|
|
128
|
-
|
|
117
|
+
|
|
129
118
|
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
|
130
119
|
timeoutCancellable?.cancel()
|
|
131
120
|
timeoutCancellable = nil
|
|
132
|
-
print("======================> timeoutCancellable 2")
|
|
133
|
-
|
|
134
121
|
guard let latestLocation = locations.last else {
|
|
135
|
-
|
|
136
|
-
print("======================> currentLocation 1")
|
|
137
122
|
currentLocation = nil
|
|
138
123
|
return
|
|
139
124
|
}
|
|
140
|
-
|
|
141
|
-
print("======================> currentLocation 2")
|
|
142
125
|
currentLocation = IONGLOCPositionModel.create(from: latestLocation)
|
|
143
126
|
}
|
|
144
|
-
|
|
127
|
+
|
|
145
128
|
public func locationManager(_ manager: CLLocationManager, didFailWithError error: any Error) {
|
|
146
|
-
print("======================> timeoutCancellable 3")
|
|
147
129
|
timeoutCancellable?.cancel()
|
|
148
130
|
timeoutCancellable = nil
|
|
149
131
|
currentLocation = nil
|
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.2",
|
|
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",
|