spotny-sdk 1.0.36 → 1.0.39
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.
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
<!-- Location is required for beacon scanning on API < 31 -->
|
|
11
11
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
12
|
-
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
13
12
|
<!-- Background location required for background scanning -->
|
|
14
13
|
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
|
15
14
|
|
|
@@ -4,7 +4,7 @@ import android.app.NotificationChannel
|
|
|
4
4
|
import android.app.NotificationManager
|
|
5
5
|
import android.content.Context
|
|
6
6
|
import android.os.Build
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import android.util.Log
|
|
9
9
|
import androidx.core.app.NotificationCompat
|
|
10
10
|
import com.facebook.react.bridge.*
|
|
@@ -124,9 +124,8 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
124
124
|
.setContentText("Scanning for nearby beacons…")
|
|
125
125
|
.build()
|
|
126
126
|
beaconManager.enableForegroundServiceScanning(notification, 8765)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
127
|
+
beaconManager.beaconParsers.clear()
|
|
128
|
+
beaconManager.beaconParsers.add(BeaconParser().setBeaconLayout(IBEACON_LAYOUT))
|
|
130
129
|
beaconManager.foregroundScanPeriod = 1_100L
|
|
131
130
|
beaconManager.foregroundBetweenScanPeriod = 0L
|
|
132
131
|
beaconManager.backgroundScanPeriod = 10_000L
|
|
@@ -164,13 +163,11 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
override fun stopScanner(promise: Promise) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
beaconManager.stopMonitoringBeaconsInRegion(region)
|
|
173
|
-
} catch (_: RemoteException) {}
|
|
166
|
+
beaconManager.removeAllMonitorNotifiers()
|
|
167
|
+
beaconManager.removeAllRangeNotifiers()
|
|
168
|
+
val region = Region("SpotnySDK_General", Identifier.parse(BEACON_UUID), null, null)
|
|
169
|
+
beaconManager.stopRangingBeacons(region)
|
|
170
|
+
beaconManager.stopMonitoring(region)
|
|
174
171
|
|
|
175
172
|
cleanupAllState()
|
|
176
173
|
|
|
@@ -271,6 +268,9 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
271
268
|
}
|
|
272
269
|
|
|
273
270
|
override fun clearDebounceCache(promise: Promise) {
|
|
271
|
+
lastProximityEventSent.clear()
|
|
272
|
+
lastImpressionEventSent.clear()
|
|
273
|
+
lastProximityDistance.clear()
|
|
274
274
|
promise.resolve("Debounce cache cleared")
|
|
275
275
|
}
|
|
276
276
|
|
|
@@ -298,8 +298,8 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
298
298
|
beaconManager.addRangeNotifier(rangeNotifier)
|
|
299
299
|
beaconManager.addMonitorNotifier(monitorNotifier)
|
|
300
300
|
|
|
301
|
-
beaconManager.
|
|
302
|
-
beaconManager.
|
|
301
|
+
beaconManager.startRangingBeacons(region)
|
|
302
|
+
beaconManager.startMonitoring(region)
|
|
303
303
|
|
|
304
304
|
Log.d(TAG, "Scanning for UUID $BEACON_UUID")
|
|
305
305
|
}
|
|
@@ -438,7 +438,7 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
438
438
|
putString("event", "enter")
|
|
439
439
|
}
|
|
440
440
|
sendEvent("onBeaconRegionEvent", payload)
|
|
441
|
-
|
|
441
|
+
beaconManager.startRangingBeacons(region)
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
override fun didExitRegion(region: Region) {
|
|
@@ -450,7 +450,7 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
450
450
|
sendEvent("onBeaconRegionEvent", payload)
|
|
451
451
|
// FIX #3: delegate to cleanupAllState which now uses lastProximityEventSent
|
|
452
452
|
cleanupAllState()
|
|
453
|
-
|
|
453
|
+
beaconManager.stopRangingBeacons(region)
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
override fun didDetermineStateForRegion(state: Int, region: Region) {
|