scandit-react-native-datacapture-core 7.0.1 → 7.1.0-beta.1

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.
@@ -68,7 +68,7 @@ if (file( "${rootProject.projectDir}/build-test.gradle").exists()) {
68
68
  }
69
69
 
70
70
  dependencies {
71
- def sdk_version = "7.0.1"
71
+ def sdk_version = "7.1.0-beta.1"
72
72
 
73
73
  println("Version of the native sdk used in this build: ${safeExtGet('global_sdk_version', sdk_version)}")
74
74
  if (findProject(':scandit-datacapture-frameworks-core') != null) {
@@ -6,6 +6,7 @@
6
6
 
7
7
  package com.scandit.datacapture.reactnative.core.utils
8
8
 
9
+ import com.facebook.react.bridge.Arguments
9
10
  import com.facebook.react.bridge.ReactApplicationContext
10
11
  import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
11
12
  import com.scandit.datacapture.frameworks.core.events.Emitter
@@ -16,6 +17,9 @@ class ReactNativeEventEmitter(private val reactContext: ReactApplicationContext)
16
17
  private val delegate by lazy { reactContext.getJSModule<RCTDeviceEventEmitter>() }
17
18
 
18
19
  override fun emit(eventName: String, payload: MutableMap<String, Any?>) {
19
- delegate.emit(eventName, JSONObject(payload).toString())
20
+ val reactPayload = Arguments.createMap()
21
+ reactPayload.putString("name", eventName)
22
+ reactPayload.putString("data", JSONObject(payload).toString())
23
+ delegate.emit(eventName, reactPayload)
20
24
  }
21
25
  }
@@ -1,5 +1,11 @@
1
+ /*
2
+ * This file is part of the Scandit Data Capture SDK
3
+ *
4
+ * Copyright (C) 2023- Scandit AG. All rights reserved.
5
+ */
1
6
  package com.scandit.datacapture.reactnative.core.utils
2
7
 
8
+ import com.facebook.react.bridge.Arguments
3
9
  import com.facebook.react.bridge.Promise
4
10
  import com.scandit.datacapture.frameworks.core.result.FrameworksResult
5
11
  import org.json.JSONObject
@@ -7,11 +13,20 @@ import kotlin.Error
7
13
 
8
14
  class ReactNativeResult(private val promise: Promise) : FrameworksResult {
9
15
  override fun success(result: Any?) {
10
- if (result is Map<*, *>) {
11
- promise.resolve(JSONObject(result).toString())
16
+ if (result == null) {
17
+ promise.resolve(null)
12
18
  return
13
19
  }
14
- promise.resolve(result)
20
+
21
+ val resultData = if (result is Map<*, *>) {
22
+ JSONObject(result).toString()
23
+ } else {
24
+ result.toString()
25
+ }
26
+
27
+ val reactPayload = Arguments.createMap()
28
+ reactPayload.putString("data", resultData)
29
+ promise.resolve(reactPayload)
15
30
  }
16
31
 
17
32
  override fun error(errorCode: String, errorMessage: String?, errorDetails: Any?) {