RSS

QRCode Generator And Scanner For Xamarin.Forms Using ZXing Nuget

Introduction

A barcode is the representation of a numeric or alphanumeric data in the form of a symbol consisting of bars and spaces whose thickness varies according to the symbology used and the data thus encoded.

There are two general types of barcodes:

  • Unidimensional (1D)
    These codes are those represented by a series of parallel lines of variable thickness. Their reading is one-dimensional. Depending on the reading technology used, the decoding may be unidirectional or bi-directional to confirm the first decoding.

 

  • Two-dimensional (2D)
    These codes use a variety of symbols (rectangles, dots, hexagons, and other geometric shapes). This matrix form makes it possible to record more information which is also called QR codes And this is an example of a QR code which contains the same information of the previous BarCode.

This article will cover the following:

  • a) QRCode Generator
  • b) QRCode Scanner

Implementation

a) QRCode Generator:


1) After creating a cross-platform project, we should install the following NuGet package in the solution ZXing.Net.Mobile and ZXing.Net.Mobile.Forms(Right-click on the solution / Manage NuGet Packages for Solution)

1

3

2) Now in Main Page we will add the following code to generate a QRCode

2

3) For Android in Main Activity.cs add following code:

4

For iOS in AppDelegate.cs add following code:

5

4) Now Run the application. (Currently on Android Simulator)

6

b) QRCode Scanner :

1) Now moving ahead lets generate QRCode Code Scanner. Add new ContentPage to the Application. Namely QRScanner.xaml. Also change the App() method in App.xaml.cs as MainPage = new QRScanner();

2) In QRScanner.xaml add the following code:

7

3) In QRScanner.xaml.cs add the following code to scan the QR for event OnScanResult:

8

4) Now in AndroidManifest.xml add the following code:

9

5) In iOS add the following highlighted code in info.plist

10

4) Now release the application and test it on Mobile for the QR Code Generated as follows:

Screenshot_20200807-150750

 

Thank you.

 

 
Leave a comment

Posted by on August 7, 2020 in .NET TECHNOLOGIES