Camera scanning with SocketCam

Support

The React Native Capture SDK now has support for SocketCam C820. It does not yet have support for C860 but this will be added in a future release.

Requirements

In order to use SocketCam C820 in your React Native app, you will need to install or upgrade the React Native Capture SDK version 1.4 or higher.

iOS Requirements You will need to update pods because in version 1.4 we updated the iOS SDK version from 1.3.34 to 1.6.39. You may need to use pod install --repo-update. Doing a regular pod install gave me the error the below error.

::
[!] CocoaPods could not find compatible versions for pod “CaptureSDK”:
In Podfile:

react-native-capture (from ../node_modules/react-native-capture) was resolved to 1.3.37, which depends on CaptureSDK (~> 1.6.39)

In your Info.plist, you need to add the key to allow access to the camera. Add the below code to the bottom of your dict tag.

Android Requirements

In AndroidManifest.xml you will need to add the below code.

Using SocketCam C820

Once you have all of the changes above, you can start using SocketCam in your React Native App. In order to do this, in your app you will need to first enable SocketCam, using a setProperty to set the socketCamStatus property.Once it is enabled, you will then need to set the overlay view property, again using a setProperty request. Finally, to open the view finder and start scanning you can set the trigger by setting the trigger property.

Below is an example of enabling SocketCam.

And here is an example of setting the overlay view.

Finally, here is how to set the trigger property.

const triggerOptions = [
    {label: 'Start', value: Trigger.Start},
    {label: 'Stop', value: Trigger.Stop},
    {label: 'Continuous Scan', value: Trigger.ContinuousScan},
];

const setSocketCamTrigger = async () => {
    var property = new CaptureProperty(
        CapturePropertyIds.TriggerDevice,
        CapturePropertyTypes.Byte,
        triggerType,
    );

    // triggerType is a state value that is changed by toggling between options.

    try {
        var data = await socketcamDevice.setProperty(property);
        var triggerOpt = triggerOptions.find((x) => x.value === triggerType);
        setStatus(`successfully changed TriggerDevice: '${triggerOpt?.label}'`);
    } catch (err) {
        setStatus(`failed to set TriggerDevice: ${err.code} : ${err.message}`);
    }
};

In order to check if you already have SocketCam enabled, you can use a getProperty request like so.

By checking if SocketCam is enabled you won’t need to go through the trouble of re-enabling it.

Differentiating SocketCam from other devices

It is recommended in the UI to save the capture instance that is tied to SocketCam separately from other device capture instances as to avoid get/set property and usage conflicts. You can differentiate a SocketCam device from another device, such as a D740, by checking the device type in the device arrival event. See the below code from an onCaptureEvent callback.