@capacitor/geolocation 7.1.5-dev.2 → 7.1.5-dev.4

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.
@@ -1,8 +1,6 @@
1
1
  import Capacitor
2
-
3
2
  // import IONGeolocationLib
4
3
  import UIKit
5
-
6
4
  import Combine
7
5
 
8
6
  @objc(GeolocationPlugin)
@@ -218,10 +216,10 @@ private extension GeolocationPlugin {
218
216
  callbackManager?.sendRequestPermissionsSuccess(Constants.AuthorisationStatus.Status.granted)
219
217
  }
220
218
  if shouldRequestCurrentPosition {
221
- locationService?.requestSingleLocation(timeout: self.timeout)
219
+ locationService?.requestSingleLocation(options: IONGLOCRequestOptionsModel(timeout: self.timeout))
222
220
  }
223
221
  if shouldRequestLocationMonitoring {
224
- locationService?.startMonitoringLocation(timeout: self.timeout)
222
+ locationService?.startMonitoringLocation(options: IONGLOCRequestOptionsModel(timeout: self.timeout))
225
223
  }
226
224
  }
227
225
 
@@ -0,0 +1,9 @@
1
+ import Foundation
2
+
3
+ public struct IONGLOCRequestOptionsModel {
4
+ let timeout: Int
5
+
6
+ public init(timeout: Int? = nil) {
7
+ self.timeout = timeout ?? 5000
8
+ }
9
+ }
@@ -25,11 +25,11 @@ public protocol IONGLOCLocationHandler {
25
25
  }
26
26
 
27
27
  public protocol IONGLOCSingleLocationHandler: IONGLOCLocationHandler {
28
- func requestSingleLocation(timeout: Int?)
28
+ func requestSingleLocation(options: IONGLOCRequestOptionsModel)
29
29
  }
30
30
 
31
31
  public protocol IONGLOCMonitorLocationHandler: IONGLOCLocationHandler {
32
- func startMonitoringLocation(timeout: Int?)
32
+ func startMonitoringLocation(options: IONGLOCRequestOptionsModel)
33
33
  func startMonitoringLocation()
34
34
  func stopMonitoringLocation()
35
35
  }
@@ -53,10 +53,9 @@ public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
53
53
  authorisationType.requestAuthorization(using: locationManager)
54
54
  }
55
55
 
56
- public func startMonitoringLocation(timeout: Int? = nil) {
57
- let timeoutValue = timeout ?? 5000
56
+ public func startMonitoringLocation(options: IONGLOCRequestOptionsModel) {
58
57
  isMonitoringLocation = true
59
- self.startTimer(timeout: timeoutValue)
58
+ self.startTimer(timeout: options.timeout)
60
59
  locationManager.startUpdatingLocation()
61
60
  }
62
61
 
@@ -70,10 +69,7 @@ public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
70
69
  locationManager.stopUpdatingLocation()
71
70
  }
72
71
 
73
- public func requestSingleLocation(timeout: Int? = nil) {
74
- // Fallback to default timeout (5000) when the parameter is nil,
75
- // since optional defaults in Swift don't apply when nil is explicitly passed.
76
- let timeoutValue = timeout ?? 5000
72
+ public func requestSingleLocation(options: IONGLOCRequestOptionsModel) {
77
73
  // If monitoring is active meaning the location service is already running
78
74
  // and calling .requestLocation() will not trigger a new location update,
79
75
  // we can just return the current location.
@@ -81,7 +77,7 @@ public class IONGLOCManagerWrapper: NSObject, IONGLOCService {
81
77
  currentLocationForceSubject.send(location)
82
78
  return
83
79
  }
84
- self.startTimer(timeout: timeoutValue)
80
+ self.startTimer(timeout: options.timeout)
85
81
  self.locationManager.requestLocation()
86
82
  }
87
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/geolocation",
3
- "version": "7.1.5-dev.2",
3
+ "version": "7.1.5-dev.4",
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",