spotny-sdk 1.0.27 → 1.0.29

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.
package/SpotnySdk.podspec CHANGED
@@ -16,11 +16,12 @@ Pod::Spec.new do |s|
16
16
  s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
17
17
  s.private_header_files = "ios/**/*.h"
18
18
 
19
- # All three frameworks are pre-built with Swift 6.2 and bundled — no SPM or manual setup needed.
20
- # DO NOT also add KontaktSDK/CBORCoding/Half via SPM it causes duplicate framework errors.
19
+ # KontaktSDK and Half are pre-built and bundled — no SPM or manual setup needed.
20
+ # CBORCoding is statically compiled inside KontaktSDK.xcframeworkdo NOT add it separately.
21
+ # Adding CBORCoding.xcframework causes duplicate ObjC class registration, crashing on iOS 16
22
+ # in map_images_nolock and triggering hard crashes with memory-heavy frameworks (e.g. ViroKit/AR).
21
23
  s.vendored_frameworks = [
22
24
  "ios/Frameworks/KontaktSDK.xcframework",
23
- "ios/Frameworks/CBORCoding.xcframework",
24
25
  "ios/Frameworks/Half.xcframework"
25
26
  ]
26
27
 
@@ -1,8 +1,12 @@
1
1
  package com.spotnysdk
2
2
 
3
+ import android.app.NotificationChannel
4
+ import android.app.NotificationManager
3
5
  import android.content.Context
6
+ import android.os.Build
4
7
  import android.os.RemoteException
5
8
  import android.util.Log
9
+ import androidx.core.app.NotificationCompat
6
10
  import com.facebook.react.bridge.*
7
11
  import com.facebook.react.modules.core.DeviceEventManagerModule
8
12
  import org.altbeacon.beacon.*
@@ -339,6 +343,20 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
339
343
 
340
344
  val lastDist = lastProximityDistance[key]
341
345
  if (lastDist == null || (distance >= 1.0 && abs(distance - lastDist) >= proximityDistanceThreshold)) {
346
+ if (lastDist == null) {
347
+ val enterPayload = WritableNativeMap().apply {
348
+ putInt("major", major)
349
+ putInt("minor", minor)
350
+ putString("beaconId", key)
351
+ putDouble("distance", distance)
352
+ putString("region", "SpotnySDK_GeneralRegion")
353
+ }
354
+ sendEvent("onBeaconRangeEnter", enterPayload)
355
+ sendLocalNotification(
356
+ "📡 Beacon Detected",
357
+ "Major: $major, Minor: $minor — ${"%,.1f".format(distance)}m away"
358
+ )
359
+ }
342
360
  sendProximity("NEARBY", key, distance)
343
361
  lastProximityDistance[key] = distance
344
362
  lastProximityEventSent[key] = now
@@ -346,8 +364,8 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
346
364
 
347
365
  beaconLastSeen[key] = now
348
366
 
349
- // Fetch campaign when distance <= 3m
350
- if (distance <= 3.0 && campaignFetched[key] != true) {
367
+ // Fetch campaign when distance <= 5m
368
+ if (distance <= 5.0 && campaignFetched[key] != true) {
351
369
  fetchCampaign(key, major, minor)
352
370
  }
353
371
 
@@ -436,6 +454,24 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
436
454
  .emit(name, payload)
437
455
  }
438
456
 
457
+ private fun sendLocalNotification(title: String, body: String) {
458
+ val channelId = "spotny_sdk_channel"
459
+ val notifManager = reactContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
460
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
461
+ val channel = NotificationChannel(channelId, "Spotny SDK", NotificationManager.IMPORTANCE_DEFAULT)
462
+ notifManager.createNotificationChannel(channel)
463
+ }
464
+ val appIcon = reactContext.applicationInfo.icon.takeIf { it != 0 }
465
+ ?: android.R.drawable.ic_dialog_info
466
+ val notification = NotificationCompat.Builder(reactContext, channelId)
467
+ .setSmallIcon(appIcon)
468
+ .setContentTitle(title)
469
+ .setContentText(body)
470
+ .setAutoCancel(true)
471
+ .build()
472
+ notifManager.notify(System.currentTimeMillis().toInt(), notification)
473
+ }
474
+
439
475
  private fun logFile() = File(reactContext.filesDir, "spotny_beacon_debug.log")
440
476
 
441
477
  private fun logToFile(message: String) {
@@ -894,6 +894,19 @@ extension SpotnyBeaconScanner: KTKBeaconManagerDelegate {
894
894
  // FIX #9: nil lastDist already implies first detection — no separate isFirst needed
895
895
  let lastDist = lastProximityDistance[key]
896
896
  if lastDist == nil || (distance >= 1.0 && abs(distance - (lastDist ?? 0)) >= proximityDistanceThreshold) {
897
+ if lastDist == nil {
898
+ eventCallback?("onBeaconRangeEnter", [
899
+ "major": major,
900
+ "minor": minor,
901
+ "beaconId": key,
902
+ "distance": distance,
903
+ "region": "SpotnySDK_GeneralRegion"
904
+ ])
905
+ sendLocalNotification(
906
+ title: "📡 Beacon Detected",
907
+ body: "Major: \(major), Minor: \(minor) — \(String(format: "%.1f", distance))m away"
908
+ )
909
+ }
897
910
  sendProximity(eventType: "NEARBY", key: key, distance: distance)
898
911
  lastProximityDistance[key] = distance
899
912
  lastProximityEventSent[key] = now
@@ -901,8 +914,8 @@ extension SpotnyBeaconScanner: KTKBeaconManagerDelegate {
901
914
 
902
915
  beaconLastSeen[key] = now
903
916
 
904
- // Fetch campaign when distance <= 3m
905
- if distance <= 3.0 && campaignFetched[key] != true {
917
+ // Fetch campaign when distance <= 5m
918
+ if distance <= 5.0 && campaignFetched[key] != true {
906
919
  fetchCampaign(key: key, major: major, minor: minor)
907
920
  }
908
921
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spotny-sdk",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Beacon Scanner",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",