This fork improves the stability and won't crash your app.
The package are published on this github's nuget package server. See usage below.
This .NET (C#) library make scanning barcodes as effortless and painless as possible.
It supports Xamarin iOS, Android, UWP, Mac (rendering only, not scanning), Tizen.
- Add this github nuget server to your nuget sources:
#Add the source locally
dotnet nuget add source --username yourGithubUsername --password oneOfYoursGithubPersonalAccessToken --store-password-in-clear-text --name github-softlion "https://nuget.pkg.github.com/softlion/index.json"
#Or add it to you project's root directory in a nuget.config file
#Make sure your Personal Access Token has only read rights on public packages, so you can check it in git
dotnet nuget add source --configfile nuget.config --username yourGithubUsername --password oneOfYoursGithubPersonalAccessToken --store-password-in-clear-text --name github-softlion "https://nuget.pkg.github.com/softlion/index.json"
In your nuget list, you will now get an updated preview version of ZXing.Net.Mobile.Forms
.
-
Add or update the preview nuget
ZXing.Net.Mobile.Forms
-
Make sure Xamarin.Essentials is setup and initialized, including
OnRequestPermissionsResult
on Android. -
Add this initialization code just after Xamarin.Essentials:
//Android
ZXing.Net.Mobile.Forms.Android.Platform.Init();
//iOS
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
//MacOS
ZXing.Net.Mobile.Forms.MacOS.Platform.Init();
//UWP
ZXing.Net.Mobile.Forms.WindowsUniversal.Platform.Init();
Android: the Camera
permission is included for you.
If you would like to use the Flashlight API, add the Flashlight
permission:
[assembly: UsesPermission(Android.Manifest.Permission.Flashlight)]
UWP: if finishing scanning or pressing the back button is causing the page to jump back further than expected, or if the UI of a page won't update after scanning,
add NavigationCacheMode="Enabled"
on the Page
tag.
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:
There is a sample for each platform including examples of how to use custom overlays.
See https://github.com/Redth/ZXing.Net.Mobile
Based on the open source Barcode Library: ZXing (Zebra Crossing), using the ZXing.Net Port.