Skip to content

Commit 2c16465

Browse files
author
build
committed
New version of React Native CaptureSDK
1 parent 3f12b32 commit 2c16465

31 files changed

+856
-142
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Changelog
22

3-
This file tracks released versions with the changes made to this project.
3+
## Version 1.5.134
4+
5+
### Improvements
6+
7+
- Updated the [iOS CaptureSDK](https://github.com/SocketMobile/cocoapods-capturesdk) to `v1.9.166`. Read more about the latest changes on [iOS CaptureSDK here](https://github.com/SocketMobile/cocoapods-capturesdk/releases/tag/1.9.166)
8+
9+
### Fixed
10+
11+
- The [issue](https://github.com/SocketMobile/react-native-capture/issues/10) has been fixed. The React Native CaptureSDK now supports fully the new architecture
412

513
## Version 1.5.130
614

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
# React Natice CaptureSDK - Version 1.5.130
1+
# React Natice CaptureSDK - Version 1.5.134
22

33
This react native module allows a React Native application to use and control Socket Mobile wireless barcode scanners, NFC Reader/Writer, and Camera to capture and deliver data capture to such application.
44

5+
The React Native CaptureSDK now supports fully the new architecture !
6+
7+
## From 31st of July 2025 - Noticeable change from version 1.9.166
8+
9+
**From version 1.9.166 on iOS CaptureSDK:**
10+
11+
**- Users who want to use our Bluetooth LE readers, will have to install the [Socket Mobile Companion app](https://apps.apple.com/app/socket-mobile-companion/id1175638950) which takes care of the discovery and the selection of the reader to connect to.**
12+
13+
**- If you still want to use the notion of favorites with our BLE Device Manager, you can use the version 1.9.157. A future version of CaptureSDK will be available to support both worlds (favorites and Companion app).**
14+
515
## Devices compatibility and CaptureSDK versions
616

717
| Devices | <= 1.2 | 1.3 | 1.4 | 1.5 |
@@ -54,15 +64,15 @@ Once you import this component, it can be used in your app like so.
5464
/>
5565
```
5666

57-
SocketCam in your React Native app, you can check out the docs [here](https://docs.socketmobile.com/react-native-capture/en/latest/socketCam.html 'docs.socketmobile.com'). For more information specifically about `SocketCamViewContainer`, you read more [here](https://docs.socketmobile.com/react-native-capture/en/latest/socketCam.html#socketcamviewcontainer.html 'docs.socketmobile.com').
67+
SocketCam in your React Native app, [you can check out the docs here](https://docs.socketmobile.com/react-native-capture/en/latest/socketCam.html 'docs.socketmobile.com'). For more information specifically about `SocketCamViewContainer`, [you can read more here](https://docs.socketmobile.com/react-native-capture/en/latest/socketCam.html#socketcamviewcontainer.html 'docs.socketmobile.com').
5868

5969
## Custom View finder for SocketCam
6070

6171
The latest version of the React Native CaptureSDK also offers support for customizing the SocketCam view finder in your app. To do this on iOS, you can provide either custom styles for the `socketCamCustomStyle` prop or modal styles for the `socketCamCustomModalStyle` prop.
6272

6373
On Android, you can customize SocketCam by passing a React Native component to the `androidSocketCamCustomView` prop. You will also need to provide your own layout, native view manager, and custom activity.
6474

65-
For more on using custom views for SocketCam, you can read the docs [here](https://docs.socketmobile.com/react-native-capture/en/latest/socketCamCustom.html 'docs.socketmobile.com').
75+
For more on using custom views for SocketCam, [you can read the docs here](https://docs.socketmobile.com/react-native-capture/en/latest/socketCamCustom.html 'docs.socketmobile.com').
6676

6777
## Referencing Socket Mobile's Android CaptureSDK
6878

android/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ dependencies {
103103
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
104104
implementation "com.google.zxing:core:3.5.1"
105105
api "com.socketmobile:capture-socketcam:1.8.21"
106+
107+
// New Architecture (TurboModule) dependencies
108+
if (isNewArchitectureEnabled()) {
109+
implementation "com.facebook.react:react-android:+"
110+
implementation "androidx.annotation:annotation:1.6.0"
111+
}
106112
}
107-
108-
109-
110-

android/src/main/java/com/socketmobile/CaptureSdkModule.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ import com.socketmobile.capture.troy.ExtensionScope
1717
@ReactModule(name = "CaptureSdk")
1818
class CaptureSdkModule(private val reactContext: ReactApplicationContext) :
1919
ReactContextBaseJavaModule(reactContext) {
20+
21+
companion object {
22+
const val NAME = "CaptureSdk"
23+
private val TAG = CaptureSdkModule::class.java.name
24+
private const val BASE_PACKAGE = "com.socketmobile.capture"
25+
private const val SERVICE_APP_ID = "com.socketmobile.companion"
26+
private const val BROADCAST_RECEIVER = BASE_PACKAGE + ".StartService"
27+
private const val ACTION = BASE_PACKAGE + ".START_SERVICE"
28+
}
29+
30+
init {
31+
Log.i(NAME, "⚠️ CaptureSdk (Android): LEGACY ARCHITECTURE - Bridge module initialized")
32+
}
2033
private var mCaptureExtension: CaptureExtension? = null
2134
private var customDeviceHandle: Int? = null
2235
private var onDeviceHandleReady: ((Int?) -> Unit)? = null
@@ -44,7 +57,7 @@ class CaptureSdkModule(private val reactContext: ReactApplicationContext) :
4457
}
4558

4659
override fun getName(): String {
47-
return "CaptureSdk"
60+
return NAME
4861
}
4962

5063
@ReactMethod
@@ -138,11 +151,4 @@ class CaptureSdkModule(private val reactContext: ReactApplicationContext) :
138151
}
139152
}
140153

141-
companion object {
142-
private val TAG = CaptureSdkModule::class.java.name
143-
private const val BASE_PACKAGE = "com.socketmobile.capture"
144-
private const val SERVICE_APP_ID = "com.socketmobile.companion"
145-
private const val BROADCAST_RECEIVER = BASE_PACKAGE + ".StartService"
146-
private const val ACTION = BASE_PACKAGE + ".START_SERVICE"
147-
}
148154
}

android/src/main/java/com/socketmobile/CaptureSdkPackage.kt

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,65 @@ import com.facebook.react.bridge.NativeModule
55
import com.facebook.react.bridge.ReactApplicationContext
66
import com.facebook.react.uimanager.ViewManager
77

8+
// New architecture imports
9+
import com.facebook.react.TurboReactPackage
10+
import com.facebook.react.module.model.ReactModuleInfo
11+
import com.facebook.react.module.model.ReactModuleInfoProvider
12+
813

914
class CaptureSdkPackage : ReactPackage {
10-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11-
return listOf(CaptureSdkModule(reactContext))
12-
}
15+
16+
// Legacy bridge support
17+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
18+
return if (isNewArchitectureEnabled()) {
19+
// Return TurboModule for new architecture
20+
listOf(CaptureSdkTurboModule(reactContext))
21+
} else {
22+
// Return legacy module for old architecture
23+
listOf(CaptureSdkModule(reactContext))
24+
}
25+
}
26+
27+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
28+
return emptyList()
29+
}
30+
31+
// Helper method to detect new architecture
32+
private fun isNewArchitectureEnabled(): Boolean {
33+
return try {
34+
Class.forName("com.facebook.react.turbomodule.core.TurboModuleManager")
35+
true
36+
} catch (e: ClassNotFoundException) {
37+
false
38+
}
39+
}
40+
}
1341

14-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15-
return emptyList()
16-
}
42+
// TurboReactPackage implementation for new architecture
43+
class CaptureSdkTurboReactPackage : TurboReactPackage() {
44+
45+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
46+
return if (name == NativeCaptureSdkSpec.NAME) {
47+
CaptureSdkTurboModule(reactContext)
48+
} else {
49+
android.util.Log.d("CaptureSdkTurboReactPackage", "❌ Module name '$name' doesn't match '${NativeCaptureSdkSpec.NAME}'")
50+
null
51+
}
52+
}
53+
54+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
55+
return ReactModuleInfoProvider {
56+
mapOf(
57+
NativeCaptureSdkSpec.NAME to ReactModuleInfo(
58+
NativeCaptureSdkSpec.NAME,
59+
CaptureSdkTurboModule::class.java.name,
60+
false, // canOverrideExistingModule
61+
false, // needsEagerInit
62+
true, // hasConstants
63+
false, // isCxxModule
64+
true // isTurboModule
65+
)
66+
)
67+
}
68+
}
1769
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.socketmobile;
2+
3+
import com.facebook.react.bridge.ReactApplicationContext;
4+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
5+
import com.facebook.react.bridge.Promise;
6+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
7+
8+
/**
9+
* This is the definition for the TurboModule spec.
10+
* This interface defines the contract between JavaScript and native Android code.
11+
*/
12+
public abstract class CaptureSdkSpec extends ReactContextBaseJavaModule implements TurboModule {
13+
14+
public static final String NAME = "CaptureSdk";
15+
16+
CaptureSdkSpec(ReactApplicationContext context) {
17+
super(context);
18+
}
19+
20+
@Override
21+
public String getName() {
22+
return NAME;
23+
}
24+
25+
public abstract void startCaptureService(Promise promise);
26+
27+
public abstract void openTransport(String host, Promise promise);
28+
29+
public abstract void closeTransport(double handle, Promise promise);
30+
31+
public abstract void sendTransport(double handle, String jsonRpc, Promise promise);
32+
33+
public abstract void getTargetView(double reactTag);
34+
35+
public abstract void dismissViewController();
36+
37+
// SocketCam extension methods
38+
public abstract void startSocketCamExtension(double clientHandle);
39+
40+
public abstract void startSocketCamExtensionCustom(double clientHandle);
41+
42+
public abstract void getCustomDeviceHandle(Promise promise);
43+
44+
// Event emitter methods - required for RN event system
45+
public abstract void addListener(String eventType);
46+
47+
public abstract void removeListeners(double count);
48+
}

0 commit comments

Comments
 (0)