Developer’s Guide to Adding a .NET Barcode Scanner API for iOS Apps

| Developers

In Store order picking

Building or selecting an enterprise-grade .NET barcode scanner API for iOS requires more than basic image capture and processing – UX principles and performance requirements are important too. With user adoption and longevity key goals for your app, the last things you want are user complaints because the scanner doesn’t perform under real-world business conditions.

This blog explains the UX and performance considerations that lead to successful barcode scanner implementations for enterprises. Later below, we provide a getting-started tutorial for adding scanning features to iOS applications using the Scandit .NET Barcode Scanner SDK.

Why UX matters for iOS-based barcode scanning

Like staying within the memory and battery life limitations of all the iOS devices you support, integrating a .NET barcode scanner library can be time-consuming and frustrating. Avoiding the risk of burdening users with performance issues and hard-to-use features ultimately leads to improved adoption rates and happier employees.

There are numerous UX considerations to consider, ranging from assistance features to ease of use. Knowing what to implement up front brings you happier users down the road.

A good barcode scanner needs more than a good camera

Good UX design creates a positive experience for users, leading to increased engagement and user satisfaction. For applications like barcode scanners, environmental conditions and varying levels of user skills can compromise the precision and accuracy necessary for effective captures. Proper navigation, interaction, and feedback help users do their jobs, and gaps in these areas lead quickly to frustration, dissatisfaction, and complaints.

Understanding the following UX workflows helps build the best barcode scanner experience for your user base.

Starting the scanner

Mobile device users have enough on their plates without worrying about complex menu navigation or waiting for a barcode scanner to start. Good UX requires a fast and seamless transition into scanning mode, no matter what the user is doing with their device.

The following video demonstrates how the Scandit .NET Barcode Scanner SDK allows users to quickly access the scanner and work successfully in a wide variety of scanning environments.

Helping with aiming the camera

Aiming a camera can be difficult in environments where the barcode is hard to reach, or mixed in with other barcodes the user doesn’t want to scan. Building UX elements into your app that make selecting barcodes easier helps improve user efficiency and satisfaction.

Two examples of these types of elements are:

  • A viewfinder that tells users when scanning is active and helps them position the camera over the barcode correctly.
  • Restricting the scan area to help users focus on the correct barcode amidst a variety of barcodes and reduce the processing overhead on low-end devices.

Feedback and assistance

Your iOS barcode scanner implementation should provide immediate and unambiguous feedback on the success or failure of a scan. A slow response leads to user frustration. Unclear results may also lead to inaccurate and potentially noncompliant data for the business.

A combination of techniques can be used to help the user scan successfully, such as:

  • Playing audio and triggering haptic feedback when a barcode capture is successful.
  • Drawing a brush overlay at the location of the detected barcode to confirm that the intended item was scanned by the app.

Providing options for single and multiple barcode scans

Features that allow the user to switch between scanning single and multiple barcodes help them work more efficiently. Environments where the number or configuration of barcodes varies, such as a warehouse or retail store, can slow down employees if they are forced to scan one barcode at a time.

(VIDEO)

The differences between these modes are:

  • Single scan: The user triggers the scanner for every barcode, providing greater control over the scanning experience.
  • Continuous scan: The user triggers the scanner once and the app scans multiple barcodes without further interaction, reducing user fatigue.

SCAN FAST AND ACCURATELY

Test the Scandit barcode scanning SDK for .NET

Try for Free

Key development considerations when choosing a .NET barcode scanner API

Here are some other considerations to think about when building your barcode scanner for iOS applications.

1. Performance

Regardless of the iOS device and version, you should consider the following performance requirements for your app and test cases:

  • Accuracy: Barcode scanning for high-volume operations, such as inventory management, asset tracking, and last-mile delivery, requires an implementation that accurately decodes barcodes with few or no errors. Even a 95% success rate is unlikely to be good enough – you should be looking for greater than 99% success.
  • Speed: A barcode scanner that helps users capture and process barcodes fast means accelerated business operations.
  • Field-of-view and distance: Scanners must handle barcodes on items of various sizes, shapes, and distances from the camera.
  • Scanning barcodes in degraded conditions: A barcode may be torn, obscured, crumpled, or wrapped in plastic, so your solution should account for all these scenarios.
  • Start-up time: To avoid frustrated users and slower operations, your barcode scanner should support a “standby mode” that minimizes camera start-up delays between scans.
  • Capturing multiple barcodes fast: Users may need to scan multiple barcodes at once or in quick succession, such as a worker in a fulfillment center required to scan a product barcode and a location barcode fast to meet shipping times.

2. Low-light conditions

Lighting conditions in the real world vary widely between dark to brightly lit. Think about a back-of-store stockroom or a delivery driver working between day and night. Your .NET barcode scanner API should maintain speed and accuracy under all these conditions, otherwise, users will opt out of using it.

3. Large device fleets with diverse models

Enterprises often have a diverse fleet of employee devices with different camera specifications and processor architectures – especially in Bring-Your-Own-Device (BYOD) situations.

Your barcode scanner must be architected and designed to perform on iOS platforms ranging from the latest smartphone model to legacy hardware. We list key performance tests below to gauge how well your solution performs.

A solution should be highly optimized for processor performance and resource loading, and make efficient use of background tasks. The Scandit .NET Barcode Scanner SDK, for example, is built on a C/C++ foundation, ensuring that the core barcode scanning features are loaded efficiently in the background and consume minimal system resources.

4. Support for different development frameworks

For developers working in different environments, you may need to provide support for different platforms and frameworks. Scandit’s barcode scanning products are available for Native iOS, Native Android, Cordova, Xamarin (iOS, Android, and Forms), .NET Android, React Native, JavaScript, Flutter, Capacitor, and Titanium.

5. Open-source .NET barcode scanner libraries

Many .NET developers choose open-source barcode reader libraries for their ease of access and cost-effectiveness, thinking they only need basic features. The tradeoff comes when users try to use them in the real world, where speed and accuracy are critical, and where barcodes are placed in difficult-to-scan environments.

If you’re supporting a business-critical environment like a warehouse, retail stockroom, or last-mile delivery, an open-source .NET barcode reader library may not be the best choice. Commercial barcode scanner SDKs that are high-performance, accurate, and built to operate under difficult situations are often better suited for demanding enterprise use cases.

Fast, accurate, and reliable scanning with the Scandit .NET Barcode Scanner SDK

The Scandit .NET Barcode Scanner SDK, part of the Scandit Smart Data Capture Platform, allows developers to integrate a high-performance .NET barcode scanner API into iOS applications.

Rather than spend the effort building, integrating, testing, and maintaining your own code, the Scandit SDK gives you enterprise-proven features that are extensible to support your own capabilities.

The next sections explain how to implement a customizable iOS-based barcode scanning interface in just a few steps with the Scandit .NET Barcode Scanner SDK.

BARCODE SCANNING IN .NET MADE EASY

Integration is easy with ready-to-use UI components.

Free 30-day SDK Trial

Get started with the Scandit .NET Barcode Scanner SDK

Follow these steps to add the pre-built SDK features to your app for single barcode scanning. You can also test the Scandit SDK using our code samples on GitHub.

The prerequisites for these steps are:

  • The latest stable version of Visual Studio.
  • A .NET SDK.
  • A .NET for iOS project with a minimum iOS deployment target of 13.0 or higher.
  • A valid Scandit Data Capture SDK license key. You can sign up for a free test account at ssl.scandit.com.

Although not covered here, the Scandit .NET Barcode Scanner SDK also supports scanning multiple barcodes at once (batch scanning). The instructions for setting up and using this capability are located in our Get Started With MatrixScan documentation.

1. Add the SDK

The Scandit Data Capture SDK is distributed as NuGet packages, which you get from the NuGet site.

You must add the Scandit.DataCapture.Core and Scandit.DataCapture.Barcode (the ScanditBarcodeCapture API) packages, which contain the functionality for barcode scanning. When developing a MAUI application, you also need to add the Scandit.DataCapture.Core.Maui package.

You must also consider:

  • Camera permissions: When using the Scandit Data Capture SDK, you must set the camera as the frame source for various capture modes. On .NET for iOS, you have to set the “Privacy – Camera Usage Description” field in the Info.plist file.
  • When using the Scandit Data Capture SDK in a MAUI application, you have to request camera permissions in your own application before starting scanning. To see how you can achieve this, take a look at our samples.

2. Create the data capture context

To add capture capabilities to your application, you must create a new data capture context, which expects a valid Scandit Data Capture SDK license key during construction:

DataCaptureContext context = DataCaptureContext.ForLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");

3. Configure the barcode scanning behavior

Barcode scanning is orchestrated by the BarcodeCapture data capture mode. This class is the main entry point for scanning barcodes. It is configured through BarcodeCaptureSettings and registers one or more listeners that are informed whenever new codes are recognized.

For this blog, we set up barcode scanning for a small list of symbologies. Change this to the correct symbologies for your use case.

BarcodeCaptureSettings settings = BarcodeCaptureSettings.Create();
HashSet symbologies = new HashSet()
{
    Symbology.Code128,
    Symbology.Code39,
    Symbology.Qr,
    Symbology.Ean8,
    Symbology.Upce,
    Symbology.Ean13Upca
};
settings.EnableSymbologies(symbologies);

If you are not disabling barcode capture immediately after scanning the first code and do not want the same code to be scanned more than once, consider setting the BarcodeCaptureSettings.codeDuplicateFilter to around 500 or even -1.

Next, create a BarcodeCapture instance with the settings initialized in the previous step:

barcodeCapture = BarcodeCapture.Create(context, settings);

4. Register the barcode capture listener to be informed when a new barcode is scanned

To get informed whenever a new code has been recognized, add an IBarcodeCaptureListener through BarcodeCapture.addListener() and implement the listener methods to suit your application’s needs.

Implement the IBarcodeCaptureListener interface:

public void OnBarcodeScanned(BarcodeCapture barcodeCapture, BarcodeCaptureSession session, IFrameData frameData)
{
    IList barcodes = session?.NewlyRecognizedBarcodes;
    // Do something with the barcodes

    // Dispose the frame when you have finished processing it. If the frame is not properly disposed,
    // different issues could arise, e.g. a frozen, non-responsive, or "severely stuttering" video feed.
    frameData.Dispose();
}

Add the listener:

barcodeCapture.AddListener(this);

Alternatively, to register the IBarcodeCaptureListener interface, it is possible to subscribe to corresponding events. For example:

barcodeCapture.BarcodeScanned += (object sender, BarcodeCaptureEventArgs args) =>
{
    IList barcodes = args.Session?.NewlyRecognizedBarcodes;
    // Do something with the barcodes
}

5. Use the built-in camera

The data capture context supports different frame sources to perform recognition. Most applications use the built-in camera of the device, such as the rear camera of an iPhone. This blog assumes you are using the built-in camera.

On iOS, the user must explicitly grant permission for each app to access cameras. Your app needs to display static messages to the user when the system asks for camera permission. To do this, include the NSCameraUsageDescription key in your app’s Info.plist file.

The built-in camera has recommended settings for each capture mode. These should be used to achieve the best performance and user experience for the respective mode. The following code shows how to get the recommended settings and create the camera from it:

camera = Camera.GetDefaultCamera();
camera?.ApplySettingsAsync(BarcodeCapture.RecommendedCameraSettings);

As the frame source is configurable, the data capture context must be told which frame source to use via a call to DataCaptureContext.setFrameSourceAsync():

context.SetFrameSourceAsync(camera);

The camera is off by default and must be turned on by calling IFrameSource.SwitchToDesiredStateAsync() with a value of FrameSourceState.On:

camera?.SwitchToDesiredStateAsync(FrameSourceState.On);

6. Use a Capture View to visualize the scan process

When using the built-in camera as the frame source, displaying the camera preview on the screen together with UI elements that guide the capture process helps the user perform their scanning tasks.

To do this, add a DataCaptureView to your view hierarchy:

DataCaptureView dataCaptureView = DataCaptureView.Create(dataCaptureContext, View.Bounds);
View.AddSubview(dataCaptureView);

Alternatively, you can use a DataCaptureView from XAML in your MAUI application. For example:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:scandit="clr-namespace:Scandit.DataCapture.Core.UI.Maui;assembly=ScanditCaptureCoreMaui">
  <ContentPage.Content>
      <AbsoluteLayout>
          <scandit:DataCaptureView
              x:Name="dataCaptureView"
              AbsoluteLayout.LayoutBounds="0,0,1,1"
              AbsoluteLayout.LayoutFlags="All"
              DataCaptureContext="{Binding DataCaptureContext}" >
          </scandit:DataCaptureView>
      </AbsoluteLayout>
  </ContentPage.Content>
</ContentPage>

You can configure your view in the code behind class. For example:

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();

        // Initialization of DataCaptureView happens on handler changed event.
        dataCaptureView.HandlerChanged += DataCaptureViewHandlerChanged;
    }

    private void DataCaptureViewHandlerChanged(object? sender, EventArgs e)
    {
        // Your dataCaptureView configuration goes here, e.g. add overlay
    }
}

To visualize the results of barcode scanning, add the following overlay:

BarcodeCaptureOverlay overlay = BarcodeCaptureOverlay.Create(barcodeCapture, dataCaptureView);

7. Disable barcode capture

To disable barcode capture, such as when a barcode is recognized, set BarcodeCapture.Enabled to false. This stops all processing of frames after the change, but the camera continues to stream frames until it is turned off. If a frame is in the middle of processing, it is completely processed and delivers any results/callbacks to the registered listeners.

Testing barcode scanning performance

The best way to test your .NET barcode scanner API for iOS is to run it using real user scenarios. Whether you’re using your own solution or the Scandit .NET Barcode Scanner SDK, here are several performance-testing questions to ask:

  • Is there clear user guidance and feedback to foster smooth workflows rather than confuse scanning tasks?
  • Can you scan barcodes with reflections and glare?
  • Can you scan barcodes at a distance? Are you able to zoom in if needed?
  • Can you scan barcodes in different orientations, such as upside down and sideways? Flip the device upside down to see how the scanner performs.
  • Do you receive scanning feedback in loud environments and while wearing headphones?

You can also use our barcodes sample sheet for quick evaluation of your .NET barcode reader API.

Get the Scandit .NET Barcode Scanner SDK for iOS now
Brilliant UX and performance are key development goals to ensure your .NET barcode scanner API for iOS works in the real world. Fewer user frustrations and adaptability to growing business demands are far preferable to low adoption rates and bug reports.

Interested in how the Scandit .NET Barcode Scanner SDK adds intuitive, high-performance scanning to iOS apps with minimal frustration? Sign up for our free 30-day test SDK now.