spotny-sdk 1.0.24 → 1.0.26

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.
@@ -270,8 +270,12 @@ public class SpotnyBeaconScanner: NSObject {
270
270
  return
271
271
  }
272
272
 
273
+ // Clear any JWT restored from Keychain (survives uninstall) so the verify call goes out
274
+ // unauthenticated and concurrent beacon events are blocked until the new JWT arrives.
275
+ sdkToken = nil
276
+ sdkTokenExpiry = nil
277
+
273
278
  // Send token + apiKey + identifierId to backend — response returns a JWT used for all subsequent calls
274
- // sdkToken is nil here so no Authorization header is injected on this call
275
279
  let verifyPayload: [String: Any] = ["api_token": token, "api_key": key, "identifier_id": uid, "device_id": getDeviceId()]
276
280
  post(endpoint: "\(apiBasePath)/verify", payload: verifyPayload) { [weak self] result in
277
281
  guard let self = self else { return }
@@ -759,6 +763,18 @@ public class SpotnyBeaconScanner: NSObject {
759
763
  endpoint: "\(apiBasePath)/track")
760
764
  }
761
765
 
766
+ private func sendResetEventStates() {
767
+ guard sdkToken != nil else { return }
768
+ post(endpoint: "\(apiBasePath)/reset-event-states", payload: [:]) { result in
769
+ switch result {
770
+ case .success(let (status, _)):
771
+ print("📤 SpotnySDK: reset-event-states → \(status)")
772
+ case .failure(let error):
773
+ print("❌ SpotnySDK: reset-event-states failed — \(error.localizedDescription)")
774
+ }
775
+ }
776
+ }
777
+
762
778
  // MARK: - State Cleanup
763
779
 
764
780
  private func cleanupBeacon(_ key: String) {
@@ -784,8 +800,14 @@ public class SpotnyBeaconScanner: NSObject {
784
800
  }
785
801
 
786
802
  private func cleanupAllProximityState() {
787
- // FIX #3: use lastProximityEventSent — covers beacons even without campaign data
788
803
  let keys = Array(lastProximityEventSent.keys)
804
+
805
+ if keys.isEmpty {
806
+ // Killed-app wake: in-memory state lost — tell backend to close open sessions
807
+ sendResetEventStates()
808
+ return
809
+ }
810
+
789
811
  for (index, key) in keys.enumerated() {
790
812
  DispatchQueue.main.asyncAfter(deadline: .now() + Double(index) * 0.3) { [weak self] in
791
813
  self?.cleanupBeacon(key)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spotny-sdk",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "Beacon Scanner",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",