spotny-sdk 1.0.39 → 1.0.40
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.
|
@@ -113,12 +113,15 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
113
113
|
BeaconManager.setDebug(false)
|
|
114
114
|
beaconManager.setEnableScheduledScanJobs(false)
|
|
115
115
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
116
|
-
val channelId = "spotny_sdk_channel"
|
|
117
116
|
val notifManager = reactContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
notifManager.createNotificationChannel(
|
|
118
|
+
NotificationChannel("spotny_sdk_service", "Spotny Scanning", NotificationManager.IMPORTANCE_LOW)
|
|
119
|
+
)
|
|
120
|
+
notifManager.createNotificationChannel(
|
|
121
|
+
NotificationChannel("spotny_sdk_alerts", "Spotny Beacon Alerts", NotificationManager.IMPORTANCE_DEFAULT)
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
val notification = NotificationCompat.Builder(reactContext, "spotny_sdk_service")
|
|
122
125
|
.setSmallIcon(reactContext.applicationInfo.icon.takeIf { it != 0 } ?: android.R.drawable.ic_dialog_info)
|
|
123
126
|
.setContentTitle("Spotny")
|
|
124
127
|
.setContentText("Scanning for nearby beacons…")
|
|
@@ -438,6 +441,7 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
438
441
|
putString("event", "enter")
|
|
439
442
|
}
|
|
440
443
|
sendEvent("onBeaconRegionEvent", payload)
|
|
444
|
+
sendLocalNotification("📍 Beacon Region Entered", region.uniqueId)
|
|
441
445
|
beaconManager.startRangingBeacons(region)
|
|
442
446
|
}
|
|
443
447
|
|
|
@@ -448,6 +452,7 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
448
452
|
putString("event", "exit")
|
|
449
453
|
}
|
|
450
454
|
sendEvent("onBeaconRegionEvent", payload)
|
|
455
|
+
sendLocalNotification("🚪 Beacon Region Exited", region.uniqueId)
|
|
451
456
|
// FIX #3: delegate to cleanupAllState which now uses lastProximityEventSent
|
|
452
457
|
cleanupAllState()
|
|
453
458
|
beaconManager.stopRangingBeacons(region)
|
|
@@ -494,21 +499,16 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
494
499
|
}
|
|
495
500
|
|
|
496
501
|
private fun sendLocalNotification(title: String, body: String) {
|
|
497
|
-
val channelId = "spotny_sdk_channel"
|
|
498
502
|
val notifManager = reactContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
499
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
500
|
-
val channel = NotificationChannel(channelId, "Spotny SDK", NotificationManager.IMPORTANCE_DEFAULT)
|
|
501
|
-
notifManager.createNotificationChannel(channel)
|
|
502
|
-
}
|
|
503
503
|
val appIcon = reactContext.applicationInfo.icon.takeIf { it != 0 }
|
|
504
504
|
?: android.R.drawable.ic_dialog_info
|
|
505
|
-
val notification = NotificationCompat.Builder(reactContext,
|
|
505
|
+
val notification = NotificationCompat.Builder(reactContext, "spotny_sdk_alerts")
|
|
506
506
|
.setSmallIcon(appIcon)
|
|
507
507
|
.setContentTitle(title)
|
|
508
508
|
.setContentText(body)
|
|
509
509
|
.setAutoCancel(true)
|
|
510
510
|
.build()
|
|
511
|
-
notifManager.notify(System.currentTimeMillis().toInt(), notification)
|
|
511
|
+
notifManager.notify((System.currentTimeMillis() % Int.MAX_VALUE).toInt(), notification)
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
private fun logFile() = File(reactContext.filesDir, "spotny_beacon_debug.log")
|
|
@@ -339,6 +339,9 @@ public class SpotnyBeaconScanner: NSObject {
|
|
|
339
339
|
withResolve resolve: @escaping (Any?) -> Void,
|
|
340
340
|
reject: @escaping (String?, String?, Error?) -> Void
|
|
341
341
|
) {
|
|
342
|
+
lastProximityEventSent.removeAll()
|
|
343
|
+
lastImpressionEventSent.removeAll()
|
|
344
|
+
lastProximityDistance.removeAll()
|
|
342
345
|
resolve("Debounce cache cleared")
|
|
343
346
|
}
|
|
344
347
|
|