expo-beacon 0.6.6 → 0.6.7

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.
@@ -157,8 +157,11 @@ class BeaconForegroundService : Service(), BeaconConsumer {
157
157
  try { beaconManager.stopRangingBeaconsInRegion(it) } catch (_: RemoteException) {}
158
158
  }
159
159
  distanceLogRegions.clear()
160
+ monitoredRegions.forEach {
161
+ try { beaconManager.stopMonitoringBeaconsInRegion(it) } catch (_: RemoteException) {}
162
+ }
163
+ monitoredRegions.clear()
160
164
  monitoredRegionIds.clear()
161
- enteredRegions.clear()
162
165
  lastSeenAtMs.clear()
163
166
  timeoutHandler.removeCallbacksAndMessages(null)
164
167
  timeoutRunnables.clear()
@@ -167,10 +170,12 @@ class BeaconForegroundService : Service(), BeaconConsumer {
167
170
  exitCounters.clear()
168
171
  missCounters.clear()
169
172
  }
170
- monitoredRegions.forEach {
171
- try { beaconManager.stopMonitoringBeaconsInRegion(it) } catch (_: RemoteException) {}
172
- }
173
- monitoredRegions.clear()
173
+ // NOTE: enteredRegions is intentionally NOT cleared here.
174
+ // Clearing it on every reload (e.g. START_STICKY restart or repeated
175
+ // startMonitoring calls) would reset the "already entered" state and
176
+ // cause the hysteresis to fire another ENTER event for beacons that
177
+ // are still nearby. Stale entries are pruned below after new regions
178
+ // are determined.
174
179
 
175
180
  // iBeacon regions
176
181
  for (i in 0 until beacons.length()) {
@@ -230,8 +235,12 @@ class BeaconForegroundService : Service(), BeaconConsumer {
230
235
 
231
236
  // If no regions to monitor, stop the service to avoid idling
232
237
  if (monitoredRegions.isEmpty()) {
238
+ enteredRegions.clear()
233
239
  Log.d(TAG, "No paired beacons — stopping idle foreground service")
234
240
  stopSelf()
241
+ } else {
242
+ // Prune enteredRegions for regions that are no longer monitored
243
+ enteredRegions.retainAll(monitoredRegionIds)
235
244
  }
236
245
  }
237
246
 
@@ -328,21 +328,6 @@ class ExpoBeaconModule : Module(), BeaconConsumer {
328
328
  return@AsyncFunction
329
329
  }
330
330
 
331
- // Enable AltBeacon foreground service scanning so the internal BeaconService
332
- // runs as a foreground service, preventing Samsung/OEM BLE throttling.
333
- // Reset first to clear stale state from a previous session / hot-reload.
334
- if (!isBoundForScan) {
335
- try {
336
- BeaconForegroundService.ensureNotificationChannel(ctx)
337
- try { beaconManager.disableForegroundServiceScanning() } catch (_: Exception) {}
338
- beaconManager.enableForegroundServiceScanning(
339
- BeaconForegroundService.buildForegroundNotification(ctx), FOREGROUND_NOTIF_ID
340
- )
341
- } catch (_: IllegalStateException) {
342
- // Already bound — service onCreate() will enable it instead.
343
- }
344
- }
345
-
346
331
  registerEventReceiver()
347
332
  BeaconForegroundService.start(ctx)
348
333
  promise.resolve(null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-beacon",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "Expo module for scanning, pairing, and monitoring iBeacons on Android and iOS",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",