• Stars
    star
    1,067
  • Rank 43,272 (Top 0.9 %)
  • Language
    C#
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen

ZXing.Net.Mobile

Join the chat at https://gitter.im/Redth/ZXing.Net.Mobile

ZXing.Net.Mobile Logo

ZXing.Net.Mobile is a C#/.NET library based on the open source Barcode Library: ZXing (Zebra Crossing), using the ZXing.Net Port. It works with Xamarin.iOS, Xamarin.Android, Tizen, and UWP. The goal of ZXing.Net.Mobile is to make scanning barcodes as effortless and painless as possible in your own applications.

Build Status NuGet NuGet

Usage

The simplest example of using ZXing.Net.Mobile looks something like this:

buttonScan.Click += (sender, e) => {

	#if __ANDROID__
	// Initialize the scanner first so it can track the current context
	MobileBarcodeScanner.Initialize (Application);
  	#endif
  	
	var scanner = new ZXing.Mobile.MobileBarcodeScanner();

	var result = await scanner.Scan();

	if (result != null)
		Console.WriteLine("Scanned Barcode: " + result.Text);
};

Xamarin Forms

For Xamarin Forms there is a bit more setup needed. You will need to initialize the library on each platform in your platform specific app project.

Android

On Android, in your main Activity's OnCreate (..) implementation, call:

Xamarin.Essentials.Platform.Init(Application);
ZXing.Net.Mobile.Forms.Android.Platform.Init();

ZXing.Net.Mobile for Xamarin.Forms also handles the new Android permission request model for you via Xamarin.Essentials, but you will need to add the following override implementation to your main Activity as well:

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
    Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

The Camera permission should be automatically included for you in the AndroidManifest.xml however if you would like to use the Flashlight API you will still need to add the Flashlight permission yourself. You can do this by using the following assembly level attribute:

[assembly: UsesPermission (Android.Manifest.Permission.Flashlight)]
iOS

In your AppDelegate's FinishedLaunching (..) implementation, call:

ZXing.Net.Mobile.Forms.iOS.Platform.Init();
Windows Universal UWP

In your main Page's constructor, you should add:

ZXing.Net.Mobile.Forms.WindowsUniversal.Platform.Init();

If you notice that finishing scanning or pressing the back button is causing your Page to jump back further than you'd like, or if you're having trouble updating the UI of a Page after scanning is completed, you may need to set NavigationCacheMode="Enabled" within your Page's XAML <Page ... /> element.

macOS

In your AppDelegate's FinishedLaunching (..) implementation, call:

ZXing.Net.Mobile.Forms.MacOS.Platform.Init();

Features

  • Xamarin.iOS
  • Xamarin.Android
  • Tizen
  • UWP
  • Xamarin.Mac (rendering only, not scanning)
  • Simple API - Scan in as little as 2 lines of code!
  • Scanner as a View - UIView (iOS) / Fragment (Android) / Control (WP)

Custom Overlays

By default, ZXing.Net.Mobile provides a very simple overlay for your barcode scanning interface. This overlay consists of a horizontal red line centered in the scanning 'window' and semi-transparent borders on the top and bottom of the non-scanning area. You also have the opportunity to customize the top and bottom text that appears in this overlay.

If you want to customize the overlay, you must create your own View for each platform. You can customize your overlay like this:

var scanner = new ZXing.Mobile.MobileBarcodeScanner();
scanner.UseCustomOverlay = true;
scanner.CustomOverlay = myCustomOverlayInstance;
var result = await scanner.Scan();
//Handle result

Keep in mind that when using a Custom Overlay, you are responsible for the entire overlay (you cannot mix and match custom elements with the default overlay). The ZxingScanner instance has a CustomOverlay property, however on each platform this property is of a different type:

  • Xamarin.iOS => UIView
  • Xamarin.Android => View
  • UWP => UIElement

All of the platform samples have examples of custom overlays.

Barcode Formats

By default, all barcode formats are monitored while scanning. You can change which formats to check for by passing a ZxingScanningOptions instance into the StartScanning method:

//NOTE: On Android you should call the initialize method with an application instance
#if __ANDROID__
// Initialize the scanner first so it can track the current context
MobileBarcodeScanner.Initialize (Application);
#endif

var options = new ZXing.Mobile.MobileBarcodeScanningOptions();
options.PossibleFormats = new List<ZXing.BarcodeFormat>() { 
    ZXing.BarcodeFormat.Ean8, ZXing.BarcodeFormat.Ean13 
};

var scanner = new ZXing.Mobile.MobileBarcodeScanner(); 
var result = await scanner.Scan(options);
//Handle result

Samples

There is a sample for each platform including examples of how to use custom overlays.

Using the ZXingScanner View / Fragment / Control

On each platform, the ZXing scanner has been implemented as a reusable component (view, fragment, or control), and it is possible to use the reusable component directly without using the MobileBarcodeScanner class at all. On each platform, the instance of the view/fragment/control contains the necessary properties and methods required to control your scanner. By default, the default overlay is automatically used, unless you set the CustomOverlay property as well as the UseCustomOverlay property on the instance of the view/fragment/control. You can use methods such as ToggleTorch() or StopScanning() on the view/fragment/control, however you are responsible for calling StartScanning(...) with a callback and an instance of MobileBarcodeScanningOptions when you are ready for the view's scanning to begin. You are also responsible for stopping scanning if you want to cancel at any point.

The view/fragment/control classes for each platform are:

  • iOS: ZXingScannerView (UIView) - See ZXingScannerViewController.cs View Controller for an example of how to use this view
  • iOS: AVCaptureScannerView (UIView) - This is API equivalent to ZXingScannerView, but uses Apple's AVCaptureSession Metadata engine to scan the barcodes instead of ZXing.Net. See AVCaptureScannerViewController.cs View Controller for an example of how to use this view
  • Android: ZXingScannerFragment (Fragment) - See ZXingActivity.cs Activity for an example of how to use this fragment
  • UWP: ZXingScannerControl (UserControl) - See ScanPage.xaml Page for an example of how to use this Control

Using Apple's AVCaptureSession (iOS7 Built in) Barcode Scanning

In iOS7, Apple added some API's to allow for scanning of barcodes in an AVCaptureSession. The latest version of ZXing.Net.Mobile gives you the option of using this instead of the ZXing scanning engine. You can use the AVCaptureScannerView or the AVCaptureScannerViewController classes directly just the same as you would use their ZXing* equivalents. Or, in your MobileBarcodeScanner, there is now an overload to use the AV Capture Engine:

//Scan(MobileBarcodeScanningOptions options, bool useAVCaptureEngine)
scanner.Scan(options, true);

In the MobileBarcodeScanner, even if you specify to use the AVCaptureSession scanning, it will gracefully degrade to using ZXing if the device doesn't support this (eg: if it's not iOS7 or newer), or if you specify a barcode format in your scanning options which the AVCaptureSession does not support for detection. The AVCaptureSession can only decode the following barcodes:

  • Aztec
  • Code 128
  • Code 39
  • Code 93
  • EAN13
  • EAN8
  • PDF417
  • QR
  • UPC-E

Thanks

ZXing.Net.Mobile is a combination of a lot of peoples' work that I've put together (including my own). So naturally, I'd like to thank everyone who's helped out in any way. Those of you I know have helped I'm listing here, but anyone else that was involved, please let me know!

License

Apache ZXing.Net.Mobile Copyright 2012 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/).

ZXing.Net

ZXing.Net is released under the Apache 2.0 license. ZXing.Net can be found here: https://github.com/micjahn/ZXing.Net A copy of the Apache 2.0 license can be found here: https://github.com/micjahn/ZXing.Net/blob/master/COPYING

ZXing

ZXing is released under the Apache 2.0 license. ZXing can be found here: http://code.google.com/p/zxing/ A copy of the Apache 2.0 license can be found here: https://github.com/zxing/zxing/blob/master/LICENSE

System.Drawing

The System.Drawing classes included are from the mono source code which is property of Novell. Copyright notice is intact in source code files.

More Repositories

1

PushSharp

A server-side library for sending Push Notifications to iOS (iPhone/iPad APNS), Android (C2DM and GCM - Google Cloud Message), Windows Phone, Windows 8, Amazon, Blackberry, and (soon) FirefoxOS devices!
C#
4,362
star
2

dotnet-maui-check

.NET MAUI Check tool
C#
474
star
3

ZXing.Net.Maui

Barcode Scanning for MAUI?
C#
416
star
4

ResizetizerNT

Add SVG's and PNG's to your shared Xamarin Project
C#
319
star
5

APNS-Sharp

Apple Push Notification & Feedback Services Client C# Library
C#
255
star
6

Maui.VirtualListView

A slim ListView implementation for .NET MAUI that uses Platform virtualized lists / collections
C#
226
star
7

FlamedTVLauncher

A replacement home launcher for Amazon FireTV
C#
189
star
8

HttpTwo

A basic C# HTTP/2 client library
JavaScript
117
star
9

Maui.UITesting

Experimenting with UI Testing approaches for .NET / MAUI
C#
103
star
10

MAUI.AppLinks.Sample

Sample .NET MAUI app which supports deep linking
C#
54
star
11

AndroidSdk.Tools

.NET Library + global tool for various Android SDK Manager, ADB, AVD, Emulator commands
C#
52
star
12

Microsoft.Maui.Platform.Channels

A simple bridge for messaging between .NET and iOS/MacCatalyst/Android Platforms at runtime
C#
51
star
13

Resizetizer

Easily automateable Image resizing for your Xamarin.iOS and Xamarin.Android app assets!
C#
47
star
14

MSSolutionLauncher

Launch multiple instances of Visual Studio for Mac and/or Xamarin Studio easily!
C#
46
star
15

FlatUI.Xamarin.Android

FlatUI Port for Xamarin.Android of CengaLabs FlatUI Kit by @eluleci
C#
46
star
16

C2DM-Sharp

C# Client and Server Libraries for Android C2DM (Cloud 2 Device Messaging)
C#
42
star
17

Xamarin.Binding.Helpers

MSBuild Tasks to help with Binding projects for Xamarin Android and iOS
C#
40
star
18

Android.Signature.Tool

Simple GUI tool for Mac and Windows to help find the SHA1 and MD5 hashes of your Android keystore's and apk's
C#
38
star
19

AppleDev.Tools

.NET Library with useful Apple/Xcode tool wrappers and implementations for developers
C#
37
star
20

MonoDroid.UrlImageViewHelper

C# / Mono for Android Port of koush's UrlImageViewHelper
C#
35
star
21

Xamarin.AppleSignIn.Sample

A sample of how to implement Apple Sign In in Xamarin.Forms for Android, iOS, and UWP
C#
32
star
22

WshLst

Wish List App for Xamarin Developer Showdown
C#
32
star
23

Microsoft.Maui.Icons

Simple project to extract glyphs from icon fonts and generate consts for their names and unicode values
C#
23
star
24

LogcatSharp

ADB Logcat viewer written in C# using Winforms
C#
22
star
25

GCMSharp

Google Cloud Messaging Client & Server Libraries ported to C#
C#
22
star
26

GCM.Client

[DEPRECATED] Add Google Cloud Messaging to your Xamarin.Android application
C#
22
star
27

PassKitSharp

C# / .NET Library for Reading and Writing PassKit files
C#
21
star
28

XamarinEncapsulateNativeSample

An example of how to encapsulate native SDK's with easy bindings to simple API's
C#
18
star
29

xf-to-maui

C#
16
star
30

Xamarin.AspNetCore.Authentication

Add authentication to your Xamarin apps using Asp.Net Core's built in authentication and providers
C#
15
star
31

JabbRIsMobile

MvvmCross based set of mobile apps for JabbR
C#
14
star
32

EggsToGo

Xamarin Cross Platform mobile library for implementing Easter Eggs!
C#
13
star
33

AppStoreConnectNet

.NET Client Library for Apple's AppStoreConnect API's
C#
12
star
34

Maui.Generators.Prototype

A playground with some conceptual generators that could be used in Maui / Single Project
C#
12
star
35

MonoTouch.UrlImageStore

A Url Image Store for Lazy Loading Images
C#
11
star
36

MavenNet

A C# Client for inspecting and interacting with Maven Repositories
C#
11
star
37

XamarinMultiWindowTesting

C#
11
star
38

Plugin.Maui.PoppedContentView

Simple popup control & service for .NET MAUI
C#
11
star
39

iOS.BackgroundFetch.Sample

Xamarin.iOS Recipe for implementing Background Fetching
C#
9
star
40

MonoDroid.UrlImageStore

A Url Image Store for Lazy Loading Images for MonoDroid
C#
9
star
41

Xamarin.AndroidBinderator

An engine to generate Xamarin Binding projects from Maven repositories with a JSON config and razor templates
C#
9
star
42

MauiExceptionsGottaCatchEmAll

Playing with exception handling in MAUI
C#
8
star
43

XamarinSingleProjectConcept

Working area for development a concept of what Single Projects could look like for Xamarin in net6
C#
8
star
44

NestSharp

A Portable NEST API Client for C#/.NET
C#
7
star
45

Google.Auth

Google OAuth Library for C#
C#
7
star
46

Svg2VectorDrawable.Net

C# port of Android Studio's Svg2Vector code
C#
7
star
47

Xamarin.Android.Xposed

Xamarin bindings for the Android Xposed client
C#
7
star
48

Plugin.SocialAuth

Xamarin Plugin to assist with Native social authentication
C#
6
star
49

XamarinStudio.RedthsAddin

Redth's Addins. Extensions for MonoDevelop/Xamarin Studio to improve productivity.
C#
6
star
50

MonoTouch.ImageGallery

Image Gallery View Controller
6
star
51

Xamarin.Wear.WatchFace

An Android Wear watch face made with Xamarin
C#
6
star
52

MAUI.Slim.Bindings

Examples of Slim binding patterns for use within .NET MAUI projects
5
star
53

MapboxSlimBindingDemo

Java
5
star
54

Wikitude.Xamarin

Xamarin.iOS and Xamarin.Android Bindings for Wikitude SDK
JavaScript
5
star
55

MavenRepoBrowser

Xamarin.Forms app for browsing a Maven Repo (Google's)
C#
4
star
56

GitHubReleaseNotesGenerator

A simple git/github based release notes generator
C#
4
star
57

Techorama-2014

My code, slides, etc. From Techorama 2014
C#
4
star
58

Talks

Objective-C
4
star
59

ZxingSharp.Mobile

Renamed to ZXing.Net.Mobile
4
star
60

Xamarin.ChromeCustomTabs

How to use Chrome Custom Tabs in your Xamarin.Android apps!
C#
4
star
61

UnitTests.HeadlessRunner

A platform agnostic netstandard20 unit test runner
C#
4
star
62

ImapiNet

IMAPI .NET Wrapper
C#
3
star
63

MauiIssueReproBrowser

C#
3
star
64

MauiAppCIPlayground

Just a place to play with building maui apps via CI
C#
3
star
65

PushSharp.ClientSamples

Xamarin Client Samples for registering for Push notifications
C#
3
star
66

PptxNotes

Easily export notes from a .pptx to .md and Import into your .pptx from .md
C#
3
star
67

MsiSneakAttack

List and remove those hard to clean .MSI installs!
C#
3
star
68

MauiCollectionViewGallery

Some usages of CollectionView in a MAUI app to test bugs / performance against
C#
3
star
69

dotNUT

.NET implementation of the NUT protocol
C#
3
star
70

Maui.GoogleMobileAds.iOS

iOS Bindings for Google's Mobile Ads SDK to use in .NET MAUI
C#
3
star
71

Maui.Onboarding

Docs, scripts, helpers, and more to configure your environment easily for .NET MAUI development
PowerShell
2
star
72

Xamarin.PlatformMessaging

C#
2
star
73

JdwpDotNet

JDWP (Java Debug Wire Protocol) Implementation in .NET
C#
2
star
74

FbSharp.MonoTouch.Authorization

MonoTouch Facebook Authorization Controller
2
star
75

Xamarin.CI

Simple code to test Continuous Integration
C#
2
star
76

NearbyMonkey

A sample app showing off the Nearby Messages API from Google
C#
2
star
77

Xamarin.PlatformMessaging.Sample

A Sample app using Platform Messaging features
C#
2
star
78

NuGetXamarinCompatibility

Test project to test Microsoft NuGet Packages (HTTP Client, BCL, BCL.Build) compatibility with Xamarin.Android, Xamarin.iOS, and Xamarin PCL projects
C#
2
star
79

Cake.Xamarin.Build

Cake addin for Xamarin product builds
C#
2
star
80

TwilioXamarinBindings

Twilio Bindings for Xamarin apps
C#
2
star
81

Xamarin.HttpClient.Repro

C#
2
star
82

Xappium.Maui.Playground

Just a repo to start testing Xappium UITesting with MAUI apps
C#
2
star
83

MauiEdgeToEdge

Playing around with edge to edge apps and safe areas
C#
2
star
84

FbSharp

C# Library for Facebook Graph API
1
star
85

Zxing

Zxing pull from subversion
1
star
86

f50

C#
1
star
87

GoogleSignInMigration

Sample Xamarin.iOS showing how to use the new Google SignIn API's with the old Plus API's
C#
1
star
88

redth.github.com

Redth
1
star
89

Plugin.Maui.Dev

A helpful package for .NET MAUI Plugin authors to make their dev experience more delightful
1
star
90

CvPlayground

Testing UICollectionView for learnings to apply to MAUI VirtualListView
C#
1
star
91

StreamDeck.Sp108e

Stream Deck Plugin for the SP108E WiFi LED Controller
HTML
1
star
92

homebridge-poolmath-automation

HomeBridge Plugin for PoolMath Automation Controller
TypeScript
1
star
93

CorsProxy

Simple CORS Proxy intended to help with development of WebAssembly apps
C#
1
star
94

AndroidSupportComponents

C#
1
star
95

xUnit.ResultWriter

Write xUnit v2 XML Result files without xUnit
C#
1
star
96

SingleAppEntryPointExperiments

C#
1
star
97

Cake.MonoApiTools

Mono API Tools (Info, Diff, HTML Diff)
C#
1
star
98

ZXing-bindings

MonoTouch bindings for the ZXing for iPhone
C#
1
star
99

VsCodeDotNetInterop

A nice example of using a dotnet exe from VSCode to invoke commands and return results
C#
1
star
100

try_git

1
star