spotny-sdk 0.3.6 → 0.3.8
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.
Potentially problematic release.
This version of spotny-sdk might be problematic. Click here for more details.
- package/README.md +7 -8
- package/android/src/main/java/com/spotnysdk/SpotnySdkModule.kt +6 -1
- package/ios/SpotnyBeaconScanner.swift +8 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +2 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# spotny-sdk
|
|
2
2
|
|
|
3
|
-
A React Native SDK for iBeacon
|
|
3
|
+
A React Native SDK for iBeacon proximity detection. Detects nearby beacons, fires region enter/exit events, and powers real-time proximity experiences on iOS and Android.
|
|
4
4
|
|
|
5
5
|
> Requires **React Native 0.73+** with the New Architecture (Turbo Modules) enabled.
|
|
6
6
|
|
|
@@ -106,7 +106,7 @@ Starts BLE beacon scanning and begins ranging / monitoring regions.
|
|
|
106
106
|
| Parameter | Type | Required | Description |
|
|
107
107
|
| ---------- | ---------------- | -------- | ----------------------------------------------- |
|
|
108
108
|
| `userUUID` | `string` | Yes | Unique identifier for this installation/session |
|
|
109
|
-
| `userId` | `number \| null` | No | Authenticated user ID
|
|
109
|
+
| `userId` | `number \| null` | No | Authenticated user ID |
|
|
110
110
|
|
|
111
111
|
Returns `Promise<string>` — resolves with a status message.
|
|
112
112
|
|
|
@@ -144,16 +144,15 @@ const scanning = await isScanning();
|
|
|
144
144
|
|
|
145
145
|
Overrides SDK defaults. **Must be called before `startScanner`.**
|
|
146
146
|
|
|
147
|
-
| Option | Type | Default | Description
|
|
148
|
-
| ---------------------- | -------- | ------- |
|
|
149
|
-
| `maxDetectionDistance` | `number` | `8.0` | Maximum beacon detection radius (metres)
|
|
150
|
-
|
|
151
|
-
> The backend URL and Kontakt.io API key are fixed internally and cannot be overridden by consumers.
|
|
147
|
+
| Option | Type | Default | Description |
|
|
148
|
+
| ---------------------- | -------- | ------- | ------------------------------------------------------------------------------- |
|
|
149
|
+
| `maxDetectionDistance` | `number` | `8.0` | Maximum beacon detection radius (metres) |
|
|
150
|
+
| `source` | `string` | – | Identifier for your brand or app (e.g. `'nike'`). |
|
|
152
151
|
|
|
153
152
|
Returns `Promise<string>`.
|
|
154
153
|
|
|
155
154
|
```ts
|
|
156
|
-
await configure({ maxDetectionDistance: 12 });
|
|
155
|
+
await configure({ maxDetectionDistance: 12, source: 'nike' });
|
|
157
156
|
```
|
|
158
157
|
|
|
159
158
|
---
|
|
@@ -45,6 +45,8 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
45
45
|
// backendURL is fixed — not overridable by consumers.
|
|
46
46
|
private val backendURL = "https://api.spotny.app"
|
|
47
47
|
private var maxDetectionDistance = 8.0 // metres
|
|
48
|
+
/** Company/brand name identifying the SDK consumer (e.g. "nike"). */
|
|
49
|
+
private var source: String? = null
|
|
48
50
|
|
|
49
51
|
// ── Timing constants ──────────────────────────────────────────────────────
|
|
50
52
|
private var campaignFetchCooldown = 5_000L // ms
|
|
@@ -137,6 +139,7 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
137
139
|
override fun configure(config: ReadableMap?, promise: Promise) {
|
|
138
140
|
config?.getDouble("maxDetectionDistance").takeIf { config?.hasKey("maxDetectionDistance") == true }
|
|
139
141
|
?.let { maxDetectionDistance = it; Log.d(TAG, "maxDetectionDistance = $it m") }
|
|
142
|
+
config?.getString("source")?.let { source = it; Log.d(TAG, "source = $it") }
|
|
140
143
|
promise.resolve("Configuration updated")
|
|
141
144
|
}
|
|
142
145
|
|
|
@@ -422,7 +425,8 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
422
425
|
fetchInProgress[key] = true
|
|
423
426
|
|
|
424
427
|
val payload = mutableMapOf<String, Any?>("beacon_id" to key, "device_id" to deviceId)
|
|
425
|
-
userId?.let
|
|
428
|
+
userId?.let { payload["user_id"] = it }
|
|
429
|
+
source?.let { payload["source"] = it }
|
|
426
430
|
|
|
427
431
|
post("/api/app/campaigns/beacon", payload) { status, body ->
|
|
428
432
|
fetchInProgress[key] = false
|
|
@@ -489,6 +493,7 @@ class SpotnySdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
489
493
|
campaign.campaignId?.let { payload["campaign_id"] = it }
|
|
490
494
|
campaign.sessionId?.let { payload["session_id"] = it }
|
|
491
495
|
userId?.let { payload["user_id"] = it }
|
|
496
|
+
source?.let { payload["source"] = it }
|
|
492
497
|
|
|
493
498
|
post(endpoint, payload) { status, body ->
|
|
494
499
|
if (status in 200..299) {
|
|
@@ -49,6 +49,8 @@ public class SpotnyBeaconScanner: NSObject {
|
|
|
49
49
|
private let backendURL: String = "https://api.spotny.app"
|
|
50
50
|
private let kontaktAPIKey: String = "mgrz08TOKNHafeY02cWIs9mxUHbynNQJ"
|
|
51
51
|
private var maxDetectionDistance: Double = 8.0
|
|
52
|
+
/// Company/brand name that identifies the SDK consumer (e.g. "nike").
|
|
53
|
+
private var source: String?
|
|
52
54
|
|
|
53
55
|
// ── Beacon UUID (standard Kontakt.io default) ─────────────────────────────
|
|
54
56
|
private let beaconUUID = UUID(uuidString: "f7826da6-4fa2-4e98-8024-bc5b71e0893e")!
|
|
@@ -185,6 +187,10 @@ public class SpotnyBeaconScanner: NSObject {
|
|
|
185
187
|
maxDetectionDistance = dist
|
|
186
188
|
print("⚙️ SpotnySDK: maxDetectionDistance = \(dist)m")
|
|
187
189
|
}
|
|
190
|
+
if let src = config["source"] as? String {
|
|
191
|
+
source = src
|
|
192
|
+
print("⚙️ SpotnySDK: source = \(src)")
|
|
193
|
+
}
|
|
188
194
|
resolve("Configuration updated")
|
|
189
195
|
}
|
|
190
196
|
|
|
@@ -382,6 +388,7 @@ public class SpotnyBeaconScanner: NSObject {
|
|
|
382
388
|
|
|
383
389
|
var payload: [String: Any] = ["beacon_id": key, "device_id": deviceId]
|
|
384
390
|
if let uid = userId { payload["user_id"] = uid }
|
|
391
|
+
if let src = source { payload["source"] = src }
|
|
385
392
|
|
|
386
393
|
post(endpoint: "/api/app/campaigns/beacon", payload: payload) { [weak self] result in
|
|
387
394
|
guard let self = self else { return }
|
|
@@ -454,6 +461,7 @@ public class SpotnyBeaconScanner: NSObject {
|
|
|
454
461
|
if let cid = campaign.campaignId { payload["campaign_id"] = cid }
|
|
455
462
|
if let sid = campaign.sessionId { payload["session_id"] = sid }
|
|
456
463
|
if let uid = userId { payload["user_id"] = uid }
|
|
464
|
+
if let src = source { payload["source"] = src }
|
|
457
465
|
|
|
458
466
|
post(endpoint: endpoint, payload: payload) { [weak self] result in
|
|
459
467
|
guard let self = self else { return }
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","NativeSpotnySdk","SpotnyEvents","ON_BEACONS_RANGED","ON_BEACON_REGION_EVENT","eventEmitter","SpotnySdk","startScanner","userUUID","userId","stopScanner","isScanning","configure","config","requestNotificationPermissions","getDebugLogs","clearDebugLogs","setDebounceInterval","interval","clearDebounceCache","getDebounceStatus","addBeaconsRangedListener","callback","addListener","addBeaconRegionListener"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,OAAOC,eAAe,MAAM,sBAAmB;;AAE/C;AACA,OAAO,MAAMC,YAAY,GAAG;EAC1BC,iBAAiB,EAAE,iBAAiB;EACpCC,sBAAsB,EAAE;AAC1B,CAAU;;AAEV;;
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","NativeSpotnySdk","SpotnyEvents","ON_BEACONS_RANGED","ON_BEACON_REGION_EVENT","eventEmitter","SpotnySdk","startScanner","userUUID","userId","stopScanner","isScanning","configure","config","requestNotificationPermissions","getDebugLogs","clearDebugLogs","setDebounceInterval","interval","clearDebounceCache","getDebounceStatus","addBeaconsRangedListener","callback","addListener","addBeaconRegionListener"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,OAAOC,eAAe,MAAM,sBAAmB;;AAE/C;AACA,OAAO,MAAMC,YAAY,GAAG;EAC1BC,iBAAiB,EAAE,iBAAiB;EACpCC,sBAAsB,EAAE;AAC1B,CAAU;;AAEV;;AAgCA;AACA,MAAMC,YAAY,GAAG,IAAIN,kBAAkB,CAACC,aAAa,CAACM,SAAS,CAAC;;AAEpE;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAC1BC,QAAgB,EAChBC,MAAsB,EACL;EACjB,OAAOR,eAAe,CAACM,YAAY,CAACC,QAAQ,EAAEC,MAAM,IAAI,IAAI,CAAC;AAC/D;;AAEA;AACA,OAAO,SAASC,WAAWA,CAAA,EAAoB;EAC7C,OAAOT,eAAe,CAACS,WAAW,CAAC,CAAC;AACtC;;AAEA;AACA,OAAO,SAASC,UAAUA,CAAA,EAAqB;EAC7C,OAAOV,eAAe,CAACU,UAAU,CAAC,CAAC;AACrC;;AAEA;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACC,MAAuB,EAAmB;EAClE,OAAOZ,eAAe,CAACW,SAAS,CAACC,MAAgB,CAAC;AACpD;;AAEA;;AAEA;AACA,OAAO,SAASC,8BAA8BA,CAAA,EAAoB;EAChE,OAAOb,eAAe,CAACa,8BAA8B,CAAC,CAAC;AACzD;;AAEA;;AAEA;AACA,OAAO,SAASC,YAAYA,CAAA,EAAoB;EAC9C,OAAOd,eAAe,CAACc,YAAY,CAAC,CAAC;AACvC;;AAEA;AACA,OAAO,SAASC,cAAcA,CAAA,EAAoB;EAChD,OAAOf,eAAe,CAACe,cAAc,CAAC,CAAC;AACzC;;AAEA;;AAEA;AACA,OAAO,SAASC,mBAAmBA,CAACC,QAAgB,EAAmB;EACrE,OAAOjB,eAAe,CAACgB,mBAAmB,CAACC,QAAQ,CAAC;AACtD;;AAEA;AACA,OAAO,SAASC,kBAAkBA,CAAA,EAAoB;EACpD,OAAOlB,eAAe,CAACkB,kBAAkB,CAAC,CAAC;AAC7C;;AAEA;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAoB;EACnD,OAAOnB,eAAe,CAACmB,iBAAiB,CAAC,CAAC;AAC5C;;AAEA;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,QAA4C,EAC5C;EACA,OAAOjB,YAAY,CAACkB,WAAW,CAC7BrB,YAAY,CAACC,iBAAiB,EAC9BmB,QACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,uBAAuBA,CACrCF,QAA4C,EAC5C;EACA,OAAOjB,YAAY,CAACkB,WAAW,CAC7BrB,YAAY,CAACE,sBAAsB,EACnCkB,QACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -25,6 +25,8 @@ export type BeaconRegionEvent = {
|
|
|
25
25
|
export type SpotnySdkConfig = {
|
|
26
26
|
/** Maximum BLE detection distance in metres (default: 8.0) */
|
|
27
27
|
maxDetectionDistance?: number;
|
|
28
|
+
/** Identifier for your brand or app (e.g. 'nike'). */
|
|
29
|
+
source?: string;
|
|
28
30
|
};
|
|
29
31
|
/**
|
|
30
32
|
* Start beacon scanning.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAIX,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;CACn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ACjB,CAAC;AAOF;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,mDAAmD;AACnD,wBAAgB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAE7C;AAED,uDAAuD;AACvD,wBAAgB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAE7C;AAID;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAElE;AAID,gEAAgE;AAChE,wBAAgB,8BAA8B,IAAI,OAAO,CAAC,MAAM,CAAC,CAEhE;AAID,yCAAyC;AACzC,wBAAgB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAE9C;AAED,2CAA2C;AAC3C,wBAAgB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAEhD;AAID,gEAAgE;AAChE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAErE;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEpD;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEnD;AAID;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,4CAM7C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,4CAM7C"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -35,6 +35,8 @@ export type BeaconRegionEvent = {
|
|
|
35
35
|
export type SpotnySdkConfig = {
|
|
36
36
|
/** Maximum BLE detection distance in metres (default: 8.0) */
|
|
37
37
|
maxDetectionDistance?: number;
|
|
38
|
+
/** Identifier for your brand or app (e.g. 'nike'). */
|
|
39
|
+
source?: string;
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
// ── Internal event emitter ───────────────────────────────────────────────────
|