# Camera scanning with SocketCam

Requirements for using SocketCam, Socket Mobile

## Requirements

The application receives the decoded data with the same **Capture Helper event** that are used for the physical readers and they can also be used to manage some of the SocketCam properties the same way you would for a physical reader.

There are some requirements to use SocketCam:

1. A software trigger button must be added in your application's UI to trigger SocketCam using the camera.

2. Then there are some requirements depending on the platform:

## Android

> **Note**
>
> The Socket Mobile Companion app is required and can be downloaded from the <a href="https://play.google.com/store/apps/details?id=com.socketmobile.companion">Google Play Store</a>.

## build.gradle Requirements

- SocketCam is part of the **capture-socketcam** module, which the **capture-android** library already includes as a dependency. No additional dependency is required beyond the one described in [Getting Started](/docs/getting-started).

## Camera Permission

- The **android.permission.CAMERA** permission is declared in the CaptureSDK library manifest and is merged automatically into your application's **AndroidManifest.xml**.

- When SocketCam is used with its default viewfinder, CaptureSDK asks the user for the camera permission the first time a scan is triggered.

- When SocketCam is displayed in your own Activity with **SocketCamFragment** (custom viewfinder), your application *must* request the camera permission before triggering a scan.

## CaptureExtension Requirements

- SocketCam is implemented as an extension of CaptureSDK. Your application *must* start the **CaptureExtension** once the Capture client is connected, and then enable SocketCam. See [Enabling SocketCam](/docs/socketcam/implementation#enabling-socketcam).

- The CaptureExtension *must* run in the context of your application, because it needs the camera access and displays the viewfinder in the application. If CaptureSDK lives in a different layer of your architecture, such as a background service, the CaptureExtension still has to be started from the application.

- Stop the CaptureExtension when your application terminates, for instance in the **onDestroy()** of your main Activity.

## iOS

## Info.plist Requirements

- Your application's **Info.plist** *must* have the key **LSApplicationQueriesSchemes** (Queried URL Schemes) with a new item: **sktcompanion** (in lower case).

- Your application's **Info.plist** *must* have the key **NSCameraUsageDescription** with a string value explaining to the user how the app uses the camera for camera scanning purpose.

- Your application's **Info.plist** *must* have the key **CFBundleAllowMixedLocalizations** (Localized resources can be mixed) to **YES**.

## React Native

SocketCam C820 and C860 are supported by the React Native CaptureSDK (**react-native-capture**) version 2.0 and higher. The camera view is displayed with the **SocketCamViewContainer** component exported by **react-native-capture**.

## iOS Requirements

- Your application's **Info.plist** *must* have the key **LSApplicationQueriesSchemes** (Queried URL Schemes) with a new item: **sktcompanion** (in lower case).

- Your application's **Info.plist** *must* have the key **NSCameraUsageDescription** with a string value explaining to the user how the app uses the camera for camera scanning purpose.

- Your application's **Info.plist** *must* have the key **CFBundleAllowMixedLocalizations** (Localized resources can be mixed) to **YES**.

## Android Requirements

- The **CAMERA** permission is declared by the SocketCam library that **react-native-capture** depends on, and is merged into your application's manifest at build time.

- SocketCam runs as an extension that is started when **SocketCamViewContainer** is mounted. Mount it as soon as CaptureSDK is open (right after `helper.open()` resolves), with `openSocketCamView={false}`, and **before** enabling SocketCam:

```javascript
{isAndroid && helper.rootCapture && (
  <SocketCamViewContainer
    openSocketCamView={false}
    triggerType={Trigger.Start}
    clientOrDeviceHandle={helper.rootCapture.clientOrDeviceHandle}
    socketCamCapture={helper.rootCapture}
    socketCamDevice={socketCamDevice}
    handleSetSocketCamEnabled={() => {}}
    handleSetSocketCamExtensionStatus={(status) => console.log(status)}
  />
)}
```

> **Warning**
>
> If <strong>SocketCamViewContainer</strong> is not mounted before calling <code>helper.setSocketCamEnabled(true)</code>, the call fails with the error <strong>-32 (ESKT_NOTAVAILABLE)</strong> because the SocketCam extension is not running yet.

## Android Custom View

On Android, the default SocketCam view is displayed by CaptureSDK itself. To display SocketCam in your own layout, pass a React Native component to the **androidSocketCamCustomView** prop of **SocketCamViewContainer**. This requires native Android code in your application:

- A layout containing a container (for instance a **FrameLayout**) for the SocketCam fragment.
- A native view manager named **RNSocketCamCustomViewManager** exposing the **isScanContinuous** and **customViewHandle** props, registered in a **ReactPackage** added to the packages list of your **MainApplication**.
- A **FragmentActivity** inserting `SocketCamFragment.newInstance(customViewHandle, isScanContinuous)` in the fragment container, declared in your **AndroidManifest.xml**:

```xml
<activity android:name="com.your_rn_app.rn_socket_cam_custom.RNSocketCamCustomActivity" />
```

The **customViewHandle** prop is provided by **SocketCamViewContainer**; your application only needs to forward it to the fragment.

## Flutter

## iOS Info.plist Requirements

- Your application's **ios/Runner/Info.plist** *must* have the key **NSCameraUsageDescription** with a string value explaining to the user how the app uses the camera for camera scanning purpose.

- Your application's **ios/Runner/Info.plist** *must* have the key **LSApplicationQueriesSchemes** (Queried URL Schemes) with a new item: **sktcompanion** (in lower case).

- Your application's **ios/Runner/Info.plist** *must* have the key **CFBundleAllowMixedLocalizations** (Localized resources can be mixed) to **YES**.

## Android Requirements

- The [Socket Mobile Companion](https://play.google.com/store/apps/details?id=com.socketmobile.companion) app must be installed on the device, and `CapturePlugin.startCaptureService()` must complete before opening `CaptureHelper`.

- The **CAMERA** permission is declared by the SocketCam Android library included in the plugin and is merged automatically into your app's manifest. The SDK asks the user for the camera permission at runtime the first time SocketCam is triggered.

- The SocketCam extension is started automatically by `CaptureHelper.open()` and stopped by `CaptureHelper.close()`.

## Presentation modes

- **iOS**: SocketCam can be presented in full screen with `SocketCamView.presentFullScreen()` or embedded in your widget tree with the `SocketCamView` widget.

- **Android**: setting the trigger opens the SDK's own full-screen camera Activity. `SocketCamView.presentFullScreen()` and `SocketCamView.dismiss()` do nothing on Android, and embedding the `SocketCamView` widget is not supported.

## MAUI

SocketCam is included in the **SocketMobile.Capture** NuGet package for .NET MAUI. No additional package is required.

## iOS Requirements

Your MAUI project's **Info.plist** (located in **Platforms/iOS/**) *must* include the following keys:

- Your application's **Info.plist** *must* have the key **LSApplicationQueriesSchemes** (Queried URL Schemes) with a new item: **sktcompanion** (in lower case).

- Your application's **Info.plist** *must* have the key **NSCameraUsageDescription** with a string value explaining to the user how the app uses the camera for camera scanning purpose.

- Your application's **Info.plist** *must* have the key **CFBundleAllowMixedLocalizations** (Localized resources can be mixed) to **YES**.

## Android Requirements

- The **Socket Mobile Companion** app must be installed on the device. It can be downloaded from the [Google Play Store](https://play.google.com/store/apps/details?id=com.socketmobile.companion).

- A **CaptureExtension** instance must be created and started once CaptureHelper is opened. Refer to the section [Enabling SocketCam](/docs/socketcam/implementation#enabling-socketcam).

- The **CAMERA** permission is declared by the SocketCam Android library shipped in the NuGet package, and SocketCam asks the user for the camera permission at runtime.

## Windows Requirements

> **Note**
>
> Only SocketCam C820 is available on Windows.

- The **Socket Mobile Companion** software must be installed on the host PC. Download it from [GitHub](https://github.com/SocketMobile/companion-windows/releases).

- Your MAUI project's **Package.appxmanifest** (located in **Platforms/Windows/**) *must* declare the **webcam** device capability:

```xml
<Capabilities>
    <DeviceCapability Name="webcam"/>
</Capabilities>
```

- A **CaptureExtension** instance must be created with the MAUI **Window** of your application and your Windows credentials (the AppId *must* start with **windows:**), then started once CaptureHelper is opened. Refer to the section [Enabling SocketCam](/docs/socketcam/implementation#enabling-socketcam).

<br />

> **Note**
>
> CaptureSDK is designed to handle multiple devices at once. An application can enable SocketCam and can still use a physical scanner without any conflicts.

## Upgrading to SocketCam C860 (Pro)

SocketCam C860 (Pro) is an enhanced and paid version of SocketCam C820. Users will have the option to upgrade to SocketCam Pro from the SocketCam view. There are no additional code changes required to support this.

If you choose to upgrade from SocketCam C820 to SocketCam C860, you will be redirected to our Socket Mobile Companion app ([App Store](https://apps.apple.com/app/socket-mobile-companion/id1175638950) or [Google Play](https://play.google.com/store/apps/details?id=com.socketmobile.companion)) to complete the upgrade process.

You can find more details about SocketCam C860 [on our website](https://www.socketmobile.com/readers-accessories/product-families/socketcam).