SocketMobile.Capture.Xamarin.iOS 1.0.93.16

There is a newer version of this package available.
See the version list below for details.
dotnet add package SocketMobile.Capture.Xamarin.iOS --version 1.0.93.16
NuGet\Install-Package SocketMobile.Capture.Xamarin.iOS -Version 1.0.93.16
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SocketMobile.Capture.Xamarin.iOS" Version="1.0.93.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SocketMobile.Capture.Xamarin.iOS --version 1.0.93.16
#r "nuget: SocketMobile.Capture.Xamarin.iOS, 1.0.93.16"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SocketMobile.Capture.Xamarin.iOS as a Cake Addin
#addin nuget:?package=SocketMobile.Capture.Xamarin.iOS&version=1.0.93.16

// Install SocketMobile.Capture.Xamarin.iOS as a Cake Tool
#tool nuget:?package=SocketMobile.Capture.Xamarin.iOS&version=1.0.93.16

Capture SDK Version 1.0.93.16

Socket Mobile is a leading innovator of data capture and delivery solutions for enhanced productivity.

The Socket Mobile barcode scanner is an ergonomic, fast and accurate solution to a variety of data entry scenarios.

This SDK is very easy to integrate to an application without any requirement to follow a specific design architecture.

More documentation can be found here.

Quick install notes

The Capture SDK is available as NuGet package.

To install the SDK in an application, open the Manage NuGet Packages for Solution accessible through the Visual Studio Tools menu by selecting NuGet Package Manager.

A dialog displays a list of various NuGet sources. Make sure the Package source is set to either All or nuget.org. In the search box type SocketMobile.Capture.Xamarin.iOS to list the Socket Mobile Capture NuGet. Make sure to select SocketMobile.Capture.Xamarin.iOS.

An AppKey is required in order to use Capture SDK and can be generated by registering your application on Socket Mobile developer portal.

IMPORTANT: The Socket Mobile Companion should be used to connect the scanner the first time to the iOS host. The Socket Mobile Companion can be downloaded here.

Capture usage

The Capture API is described in detail in the documentation.

The recommended way of using Capture is to use CaptureHelper.cs.

1 getting a CaptureHelper instance

CaptureHelper can be instantiated by doing a simple new allocation and the reference can be kept in a field of an object where Capture is needed.

2 CaptureHelper events subscription

An application can subscribe for various events but at minimum it should subscribe to the decoded data event in order to receive the decoded data read by the Socket Mobile device.

Other events such as the device arrival and device removal can be used to track the presence of a Socket Mobile device.

The terminate event can be used in order to track when Capture has been completely shutdown or when the Socket Mobile Companion service has been terminated.

3 Opening CaptureHelper

The API for starting Capture is the OpenAsync method that needs to be invoked with the application information retrieved from the Socket Mobile developer portal, after registering the application.

Once Capture is open, then the device arrival notification occurs as soon as a device is connected to the host.

Summary for integrating Capture in a Windows project is a simple 4 step process:

  1. Add SocketMobile.Capture.Xamarin.iOS NuGet into the application solution.

  2. Add using SocketMobile.Capture; in the source where CaptureHelper should be instantiated.

  3. Subscribe for the Capture events the application is interested in.

  4. Initialize CaptureHelper by calling CaptureHelper OpenAsync method with the application information to start using Capture.

Sample code

Sample code can be found in GitHub / SocketMobile

using System;

using UIKit;
//1- add the SocketMobile Capture namespace
using SocketMobile.Capture;
using System.Threading.Tasks;

namespace scandemocapture
{
    public partial class ViewController : UIViewController
    {
        //2- instantiate the Capture Helper
        CaptureHelper capture = new CaptureHelper();

        // NOTE: each new application you create requires its own unique
        // application ID, which can be obtained from the Socket Mobile
        // Developers website.
        public async Task<long> OpenCaptureClient(CaptureHelper captureHelper)
        {
            long result = await captureHelper.OpenAsync(
                  "ios:com.socketmobile.scandemocapture",
                  "bb57d8e1-f911-47ba-b510-693be162686a",
                  "MC4CFQCfxxekfXioQRFwZQnq3PaTC6/UNwIVALRvY8iFzO8umeBv/kO5O374UOQu");
            return result;
        }

        public async Task<long> CloseCaptureClient(CaptureHelper captureHelper)
        {
            long result = await captureHelper.CloseAsync();
            return result;
        }

        // Initialize the CaptureHelper object here
        public override async void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            //3- add the various Capture event handlers we care about
            capture.DeviceArrival += OnDeviceArrival;
            capture.DeviceRemoval += OnDeviceRemoval;
            capture.DecodedData += OnDecodedData;
            capture.Errors += OnError;

            //4- open Capture Helper to start using it
            long result = await OpenCaptureClient(capture);

            if (!SktErrors.SKTSUCCESS(result))
            {
                Console.WriteLine("OpenCaptureClient failed!");
            }
        }

        // Shut down the CaptureHelper object here
        public override async void ViewWillDisappear(bool animated)
        {
            base.ViewWillDisappear(animated);

            long result = await CloseCaptureClient(capture);

            capture.DeviceArrival -= OnDeviceArrival;
            capture.DeviceRemoval -= OnDeviceRemoval;
            capture.DecodedData -= OnDecodedData;
            capture.Errors -= OnError;
        }

        // Callback for Capture, when a scanner connects
        async void OnDeviceArrival(object sender, CaptureHelper.DeviceArgs arrivedDevice)
        {
              // Friendly name is available immediately
              InvokeOnMainThread(() =>
              {
                  scannerLabel.Text = CurrentDevice.GetDeviceInfo().Name;
                  Console.WriteLine("Device friendly name is: " + CurrentDevice.GetDeviceInfo().Name);
              });
        }

        // Clear the scanner information from the text boxes on-screen when
        // the scanner goes away
        void DoScannerDisconnect()
        {
            InvokeOnMainThread(() =>
            {
                scannerLabel.Text = "";
                scannedDataLabel.Text = "";
            });
        }

        // Callback for Capture, when a scanner disconnects
        void OnDeviceRemoval(object sender, CaptureHelper.DeviceArgs removedDevice)
        {
            DoScannerDisconnect(); // do the work
        }

        // Display the scanned data on screen in the appropriate text control
        void OnDecodedData(object sender, CaptureHelper.DecodedDataArgs decodedData)
        {
            string Data = decodedData.DecodedData.DataToUTF8String;
            InvokeOnMainThread(() =>
            {
                scannedDataLabel.Text = Data;
            });
        }

        // Report Capture SDK errors on the console
        void OnError(object sender, CaptureHelper.ErrorEventArgs e)
        {
            Console.WriteLine(String.Format("OnError(): {0}", e.Message));
            if (SktErrors.SKTSUCCESS(e.Result))
                Console.WriteLine("Result is SUCCESSFUL");
            else
                Console.WriteLine("Result is FAILURE");
        }
    }
}

CaptureHelper makes the application aware of a device connection by invoking the device arrival event handler and by invoking the device removal event handler when it disconnects.

A CaptureHelperDevice represents the device that is connected can be used to retrieve or set a device property.

If the scanner triggers a scan, the decoded data can be retrieved in the decoded data event handler.

Configure and connect a Socket Mobile device

The Socket Mobile devices are shipped by default in Basic mode which is NOT compatible with the Capture SDK.

The device can be configured into the Application mode by using the Socket Mobile Companion.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Xamarin.iOS xamarinios10 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SocketMobile.Capture.Xamarin.iOS:

Package Downloads
SocketMobile.Capture

Capture SDK for C# to integrate Socket Mobile Bluetooth Scanners in your app. The Socket Mobile Companion service is required to be installed on the host.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.3.15 700 11/10/2023
1.1.33.877 2,058 12/15/2022
1.1.29.860 641 11/11/2022
1.1.9.209 2,507 10/17/2022
1.0.93.16 32,247 5/18/2019
1.0.33.32 10,029 6/22/2018
1.0.25 919 6/21/2018

First version of Capture SDK as NuGet for Xamarin iOS