spotny-sdk 1.0.34 → 1.0.36

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.
@@ -3,9 +3,8 @@
3
3
  <!-- BLE scanning -->
4
4
  <uses-permission android:name="android.permission.BLUETOOTH" />
5
5
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
6
- <!-- Android 12+ -->
7
- <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
8
- android:usesPermissionFlags="neverForLocation" />
6
+ <!-- Android 12+ — no neverForLocation so beacon RSSI data is not filtered -->
7
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
9
8
  <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
10
9
 
11
10
  <!-- Location is required for beacon scanning on API < 31 -->
@@ -16,16 +15,19 @@
16
15
 
17
16
  <!-- Run foreground service while scanning in background -->
18
17
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
19
- <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
18
+ <!-- Android 14+: BLE scanning foreground service type is connectedDevice, not location -->
19
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
20
20
 
21
21
  <uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />
22
22
 
23
23
  <application>
24
24
  <!-- AltBeacon background scanning service -->
25
+ <!-- Android 14+ requires foregroundServiceType="connectedDevice" for BLE foreground services -->
25
26
  <service android:name="org.altbeacon.beacon.service.BeaconService"
26
27
  android:enabled="true"
27
28
  android:exported="false"
28
- android:isolatedProcess="false" />
29
+ android:isolatedProcess="false"
30
+ android:foregroundServiceType="connectedDevice" />
29
31
  <service android:name="org.altbeacon.beacon.BeaconIntentProcessor"
30
32
  android:exported="false" />
31
33
  </application>
@@ -111,7 +111,22 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
111
111
 
112
112
  private fun setupBeaconManager() {
113
113
  BeaconManager.setDebug(false)
114
- beaconManager.beaconParsers.add(BeaconParser().setBeaconLayout(IBEACON_LAYOUT))
114
+ beaconManager.setEnableScheduledScanJobs(false)
115
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
116
+ val channelId = "spotny_sdk_channel"
117
+ val notifManager = reactContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
118
+ val channel = NotificationChannel(channelId, "Spotny SDK", NotificationManager.IMPORTANCE_LOW)
119
+ notifManager.createNotificationChannel(channel)
120
+ }
121
+ val notification = NotificationCompat.Builder(reactContext, "spotny_sdk_channel")
122
+ .setSmallIcon(reactContext.applicationInfo.icon.takeIf { it != 0 } ?: android.R.drawable.ic_dialog_info)
123
+ .setContentTitle("Spotny")
124
+ .setContentText("Scanning for nearby beacons…")
125
+ .build()
126
+ beaconManager.enableForegroundServiceScanning(notification, 8765)
127
+ if (beaconManager.beaconParsers.isEmpty()) {
128
+ beaconManager.beaconParsers.add(BeaconParser().setBeaconLayout(IBEACON_LAYOUT))
129
+ }
115
130
  beaconManager.foregroundScanPeriod = 1_100L
116
131
  beaconManager.foregroundBetweenScanPeriod = 0L
117
132
  beaconManager.backgroundScanPeriod = 10_000L
@@ -152,8 +167,9 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
152
167
  try {
153
168
  beaconManager.removeAllMonitorNotifiers()
154
169
  beaconManager.removeAllRangeNotifiers()
155
- beaconManager.stopRangingBeaconsInRegion(Region("SpotnySDK_General", null, null, null))
156
- beaconManager.stopMonitoringBeaconsInRegion(Region("SpotnySDK_General", null, null, null))
170
+ val region = Region("SpotnySDK_General", Identifier.parse(BEACON_UUID), null, null)
171
+ beaconManager.stopRangingBeaconsInRegion(region)
172
+ beaconManager.stopMonitoringBeaconsInRegion(region)
157
173
  } catch (_: RemoteException) {}
158
174
 
159
175
  cleanupAllState()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spotny-sdk",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "Beacon Scanner",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",