spotny-sdk 1.0.13 → 1.0.15
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.
|
@@ -150,6 +150,10 @@ public class SpotnyBeaconScanner: NSObject {
|
|
|
150
150
|
sdkTokenExpiry = Date(timeIntervalSince1970: expTs)
|
|
151
151
|
}
|
|
152
152
|
print("🔄 SpotnySDK: Resuming session (device: \(getDeviceId()))")
|
|
153
|
+
let resumeStatus = locationManager.authorizationStatus
|
|
154
|
+
if resumeStatus == .notDetermined || resumeStatus == .authorizedWhenInUse {
|
|
155
|
+
locationManager.requestAlwaysAuthorization()
|
|
156
|
+
}
|
|
153
157
|
startPersistentScanning()
|
|
154
158
|
scanning = true
|
|
155
159
|
}
|
|
@@ -167,6 +171,11 @@ public class SpotnyBeaconScanner: NSObject {
|
|
|
167
171
|
withResolve resolve: @escaping (Any?) -> Void,
|
|
168
172
|
reject: @escaping (String?, String?, Error?) -> Void
|
|
169
173
|
) {
|
|
174
|
+
let status = locationManager.authorizationStatus
|
|
175
|
+
if status == .notDetermined || status == .authorizedWhenInUse {
|
|
176
|
+
locationManager.requestAlwaysAuthorization()
|
|
177
|
+
}
|
|
178
|
+
|
|
170
179
|
if scanning {
|
|
171
180
|
resolve("Already scanning")
|
|
172
181
|
return
|
|
@@ -176,11 +185,6 @@ public class SpotnyBeaconScanner: NSObject {
|
|
|
176
185
|
UserDefaults.standard.synchronize()
|
|
177
186
|
keychainWrite(key: "SpotnySDK_sessionActive", value: "1")
|
|
178
187
|
|
|
179
|
-
let status = locationManager.authorizationStatus
|
|
180
|
-
if status == .notDetermined {
|
|
181
|
-
locationManager.requestAlwaysAuthorization()
|
|
182
|
-
}
|
|
183
|
-
|
|
184
188
|
startPersistentScanning()
|
|
185
189
|
scanning = true
|
|
186
190
|
print("✅ SpotnySDK: Started scanning (device: \(getDeviceId()))")
|
|
@@ -782,8 +786,9 @@ extension SpotnyBeaconScanner: KTKBeaconManagerDelegate {
|
|
|
782
786
|
// Build the JS event payload for ALL ranged beacons
|
|
783
787
|
let beaconPayload: [[String: Any]] = beacons.compactMap { beacon in
|
|
784
788
|
let raw = beacon.accuracy
|
|
789
|
+
guard raw > 0 else { return nil }
|
|
785
790
|
let adjusted = raw * distanceCorrectionFactor
|
|
786
|
-
guard adjusted
|
|
791
|
+
guard adjusted <= maxDetectionDistance else { return nil }
|
|
787
792
|
return [
|
|
788
793
|
"uuid": beacon.proximityUUID.uuidString,
|
|
789
794
|
"major": beacon.major.intValue,
|
|
@@ -817,9 +822,10 @@ extension SpotnyBeaconScanner: KTKBeaconManagerDelegate {
|
|
|
817
822
|
let minor = beacon.minor.intValue
|
|
818
823
|
let key = beaconKey(major: major, minor: minor)
|
|
819
824
|
let raw = beacon.accuracy
|
|
825
|
+
guard raw > 0 else { continue }
|
|
820
826
|
let distance = raw * distanceCorrectionFactor
|
|
821
827
|
|
|
822
|
-
guard distance
|
|
828
|
+
guard distance <= maxDetectionDistance else { continue }
|
|
823
829
|
|
|
824
830
|
// FIX #9: nil lastDist already implies first detection — no separate isFirst needed
|
|
825
831
|
let lastDist = lastProximityDistance[key]
|