Opx.Maui.BarcodeScanner
1.0.5
dotnet add package Opx.Maui.BarcodeScanner --version 1.0.5
NuGet\Install-Package Opx.Maui.BarcodeScanner -Version 1.0.5
<PackageReference Include="Opx.Maui.BarcodeScanner" Version="1.0.5" />
<PackageVersion Include="Opx.Maui.BarcodeScanner" Version="1.0.5" />
<PackageReference Include="Opx.Maui.BarcodeScanner" />
paket add Opx.Maui.BarcodeScanner --version 1.0.5
#r "nuget: Opx.Maui.BarcodeScanner, 1.0.5"
#:package Opx.Maui.BarcodeScanner@1.0.5
#addin nuget:?package=Opx.Maui.BarcodeScanner&version=1.0.5
#tool nuget:?package=Opx.Maui.BarcodeScanner&version=1.0.5
Opx.Maui.BarcodeScanner
Shared barcode scanner camera library for .NET MAUI 10 C#.
This project extracts the scanner pattern used by D:\projects\git\tcp-app-qualitycontrol into a reusable MAUI class library with a modern full-screen camera page, scan modes, DI registration, and image-file decoding.
Project, version metadata, and implementation source files live directly in src.
Features
- MAUI 10 class library targeting Android, iOS, MacCatalyst, and Windows.
- Uses
BarcodeScanning.Native.Maui3.1.0, the same scanner engine used by the QC reference app. - Full-screen modern camera page with translucent top/bottom controls and barcode overlay.
- Camera page includes a
Filecontrol for scanning barcode/QR images without leaving the active scan flow. - Built-in modes:
Quick,Precision,Inventory,Aim,QrOnly,FrontCamera, andImageFile. - Camera controls: flash, pause/resume, front/back camera, tap-to-focus, aim mode, viewfinder mode, capture quality, pooling, vibration, inverted-code scanning, and zoom.
- Image decode helpers from
FileResultandbyte[], plus built-in file and photo picker flows.
Add To A MAUI App
Reference the library from the app project:
<ProjectReference Include="..\maui-barcode-scan\src\Opx.Maui.BarcodeScanner.csproj" />
Register the scanner in MauiProgram.cs:
using Opx.Maui.BarcodeScanner;
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseOpxBarcodeScanner();
return builder.Build();
}
Inject and use it:
using Opx.Maui.BarcodeScanner;
public sealed class ReceivingViewModel
{
private readonly IBarcodeScanner _scanner;
public ReceivingViewModel(IBarcodeScanner scanner)
{
_scanner = scanner;
}
public async Task<string?> ScanAsync()
{
return await _scanner.ScanValueAsync(BarcodeScanOptions.ForMode(BarcodeCameraMode.Quick));
}
}
Blazor Hybrid Example
This matches the QC usage pattern where a Razor page calls a native scanner service:
@inject Opx.Maui.BarcodeScanner.IBarcodeScanner BarcodeScanner
<button @onclick="ScanBarcodeAsync">Scan</button>
@code {
private string? barcode;
private async Task ScanBarcodeAsync()
{
barcode = await BarcodeScanner.ScanValueAsync(
BarcodeScanOptions.ForMode(BarcodeCameraMode.Precision));
}
}
Permissions
Android requires API 23 or newer. Set the consumer project accordingly:
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">23.0</SupportedOSPlatformVersion>
Then add camera permissions to Platforms/Android/AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
iOS and MacCatalyst Info.plist:
<key>NSCameraUsageDescription</key>
<string>Enable camera for barcode scanning.</string>
Windows usually asks camera consent through OS privacy settings. Make sure camera access is enabled for the app.
The service asks for required camera permission before opening the modal scanner page.
Modes
| Mode | Purpose | Important defaults |
|---|---|---|
Quick |
Fast one-code scan for operational forms. | Medium quality, aim + viewfinder, auto close. |
Precision |
Difficult, small, or low-contrast labels. | Highest quality, pooling, inverted scan enabled. |
Inventory |
Collect multiple visible barcodes before closing. | High quality, pooling, no auto close. |
Aim |
Accept only the centered barcode. | Aim mode on, viewfinder off. |
QrOnly |
QR-only workflow. | BarcodeFormats.QRCode. |
FrontCamera |
Badge, kiosk, or screen-facing scans. | Front camera. |
ImageFile |
Pick an image file and decode it. | Uses the platform file picker, filtered to images, and static image decoding. |
Customize any mode:
var options = BarcodeScanOptions.ForMode(BarcodeCameraMode.Inventory);
options.Title = "Scan Item Labels";
options.Instruction = "Scan all labels on the carton";
options.PoolingInterval = 800;
options.AutoCloseOnResult = false;
options.ReturnFirstResult = false;
var response = await scanner.ScanAsync(options);
if (response.IsSuccess)
{
foreach (var result in response.Results)
Console.WriteLine($"{result.Format}: {result.Value}");
}
Image Decode
Pick an image with the platform file dialog. This is also the flow used by
ScanAsync(BarcodeScanOptions.ForMode(BarcodeCameraMode.ImageFile)):
var response = await scanner.PickAndScanFileAsync();
The camera display also has a File button. Camera detection is paused while
the picker and image decoder run. Cancelling the picker or selecting an image
without a readable barcode/QR code returns to the same camera display.
Supply custom file-picker text or image filters when needed:
var response = await scanner.PickAndScanFileAsync(new PickOptions
{
PickerTitle = "Select barcode image",
FileTypes = FilePickerFileType.Images
});
Pick an image from the device photo gallery:
var response = await scanner.PickAndScanImageAsync();
Decode a picked or received file:
FileResult file = await MediaPicker.Default.PickPhotoAsync();
var response = await scanner.ScanImageAsync(file);
Decode an image byte array:
byte[] bytes = await File.ReadAllBytesAsync(path);
var response = await scanner.ScanImageAsync(bytes);
The underlying package also documents broader static image inputs, but this wrapper intentionally exposes FileResult and byte[] because those overloads are verified against BarcodeScanning.Native.Maui 3.1.0 in this workspace.
QC Migration Note
The old QC pattern:
builder.UseBarcodeScanning();
builder.Services.AddSingleton<IBarcodeScanner, BarcodeScanner>();
can become:
builder.UseOpxBarcodeScanner();
Then replace the app-local Trust.Qc.Devices.BarcodeScanner with the shared Opx.Maui.BarcodeScanner.IBarcodeScanner.
Versioning
Package metadata is defined in Opx.Maui.BarcodeScanner.csproj:
Authors:Noviyanto WibowoCompany:OpxCopyright:Copyright (c) 2026 OpxPackageId:Opx.Maui.BarcodeScanner
The version source of truth is Opx.Maui.BarcodeScanner.Version.props.
Use the command file to increment version and validate Windows + Android builds:
version-inc.cmd patch Release
version-inc.cmd minor Release
version-inc.cmd major Release
version-inc.cmd patch Release pack
Arguments:
- First argument:
patch,minor, ormajor. Default ispatch. - Second argument:
DebugorRelease. Default isRelease. - Third argument:
packto create a NuGet package after increment/build.
The script updates VersionMajor, VersionMinor, and VersionPatch, then runs:
dotnet restore src\Opx.Maui.BarcodeScanner.csproj
dotnet build src\Opx.Maui.BarcodeScanner.csproj -c <Configuration> -f net10.0-windows10.0.19041.0 --no-restore
dotnet build src\Opx.Maui.BarcodeScanner.csproj -c <Configuration> -f net10.0-android --no-restore
Create a NuGet package without incrementing the version:
pack-nuget.cmd Release
pack-nuget.cmd Debug artifacts\packages
pack-nuget.cmd runs dotnet pack src\Opx.Maui.BarcodeScanner.csproj and writes .nupkg files to artifacts\packages by default. On this machine, pack builds and includes Android, iOS, MacCatalyst, and Windows target assemblies.
This repository has a local NuGet.config that clears machine-wide package sources and uses nuget.org only. This prevents restore from trying stale global sources such as D:\projects\repo\TRUST\Frameworks\nupkg-dist.
Verification
Verified on this machine:
dotnet build Opx.Maui.BarcodeScanner.slnx -f net10.0-windows10.0.19041.0
dotnet build src\Opx.Maui.BarcodeScanner.csproj -f net10.0-android
cmd /c pack-nuget.cmd Debug
cmd /c version-inc.cmd patch Debug
All commands succeeded with zero build warnings. Current verified package version is 1.0.5.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. net10.0-maccatalyst26.0 is compatible. net10.0-windows10.0.19041 is compatible. |
-
net10.0-android36.0
- BarcodeScanning.Native.Maui (>= 3.1.0)
- Microsoft.Maui.Controls (>= 10.0.20)
-
net10.0-ios26.0
- BarcodeScanning.Native.Maui (>= 3.1.0)
- Microsoft.Maui.Controls (>= 10.0.20)
-
net10.0-maccatalyst26.0
- BarcodeScanning.Native.Maui (>= 3.1.0)
- Microsoft.Maui.Controls (>= 10.0.20)
-
net10.0-windows10.0.19041
- BarcodeScanning.Native.Maui (>= 3.1.0)
- Microsoft.Maui.Controls (>= 10.0.20)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.